Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: tl.cpp

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

Language: cpp

Time: 0.005 second

Submitted On: 2026-08-04 02:54:19

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 310;
int n, m, a[N][N];
int ps, mi, od, ev;
int c1, c2, c3, c4;

int main() {
    ios::sync_with_stdio(0), cin.tie(0);

    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) cin >> a[i][j];
    }
    int t; cin >> t;
    for (int i = 1; i <= t; i++) {
        int x, y;
        cin >> x >> y;
        if ((x < 1 || x > n ) || (y < 1 || y > m)) {
            if (c1) ps++;
            if (c2) mi++;
            if (c3) od++;
            if (c4) ev++;
        }
        else {
            c1 = c2 = c3 = c4 = 0;
            int d = a[x][y];
            if (d > 0) {
                ps++;
                c1 = 1;
            }
            if (d < 0) {
                mi++;
                c2 = 1;
            }
            if (d % 2) {
                od++;
                c3 = 1;
            }
            else {
                ev++;
                c4 = 1;
            }
        }
    }
    cout << ps << ' ' << mi << ' ' << ev << ' ' << od;
}