Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: letdown

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

Language: cpp

Time: 0.010 second

Submitted On: 2025-10-09 20:08:14

#include <iostream>

using namespace std;
int main() {
    int r, c, n;
    cin >> r >> c;
    int a[r][c];
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            cin >> a[i][j];
        }
    }

    cin >> n;
    int xy[n][2];
    for (int i = 0; i < n; i++) {
        cin >> xy[i][0] >> xy[i][1];
    }

    // int pos=0,neg=0,even=0,odd=0;
    int plusAtIndex[4] = {0, 0, 0, 0};
    int pneo[4] = {0, 0, 0, 0};
    for (int i = 0; i < n; i++) {
        int x = xy[i][0]-1, y = xy[i][1]-1;
        if (x >= r || y >= c || x < 0 || y < 0) {
            for (int j = 0; j < 4; j++) if (plusAtIndex[j]) pneo[j]++;
            continue;
        }
        for (int j = 0; j < 4; j++) plusAtIndex[j] = 0;
        int d = a[x][y];
        if (d > 0) plusAtIndex[0] = 1;
        if (d < 0) plusAtIndex[1] = 1;
        if (d%2 == 0) plusAtIndex[2] = 1;
        else plusAtIndex[3] = 1;
        for (int j = 0; j < 4; j++) if (plusAtIndex[j]) pneo[j]++;
    }
    printf("%d %d %d %d", pneo[0], pneo[1], pneo[2], pneo[3]);
}