Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: chs_14

Problemset: สำรวจอาเรย์ 1

Language: cpp

Time: 0.008 second

Submitted On: 2026-01-18 14:01:43

#include <bits/stdc++.h>
using namespace std;

vector<int> output(4);

void check(int n) {
    if (n<0) {
        ++output[1];
    }
    else if (n>0) {
        ++output[0];
    }
    if (n%2) {
        ++output[3];
    }
    else {
        ++output[2];
    }
}

int main() {
    cin.tie(0)->sync_with_stdio();

    int R, C, K;
    cin >> R >> C;
    vector<vector<int>> table(R, vector<int>(C, 0));
    for (int i = 0; i < R; i++)
    {
        for (int j = 0; j < C; j++)
        {
            cin >> table[i][j];
        }
    }
    
    cin >> K;
    int x, y;
    for (int i = 0; i < K; i++)
    {
        cin >> x >> y;
        --x; --y;
        if (x>=0 && x < R && y >= 0 && y < C) {
            check(table[x][y]);
        }
    }

    for (int &x : output)
    {
        cout << x << ' ';
    }
    

    return 0;
}