Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: bossc

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

Language: cpp

Time: 0.009 second

Submitted On: 2026-05-05 14:11:29

#include <bits/stdc++.h>
using namespace std;
int main() {
    int r,c;
    int x,y;
    int k;
    int neg = 0;
    int pos = 0;
    int odd = 0;
    int even = 0;
    int prev1 = 0,prev2 = 0,prev3 = 0,prev4 = 0;
    cin >> r >> c;
    int arr[r][c];
    for (int i = 0;i<r;i++) {
        for (int j = 0;j<c;j++) {
            cin >> arr[i][j];
        }
    }
    cin >> k;
    for (int i = 0;i<k;i++) {
        cin >> x >> y;
        x--;
        y--;
        if (x >= 0 and y >= 0 and x < r and y < c) {
            prev1 = 0;
            prev2 = 0;
            prev3 = 0;
            prev4 = 0;
            if (arr[x][y] > 0) {
                pos++;
                prev1 = 1;
            }
            else if (arr[x][y] < 0) {
                neg++;
                prev2 = 1;
            }
            if (arr[x][y] % 2 == 0) {
                even++;
                prev3 = 1;
            }
            else if (arr[x][y] % 2 != 0) {
                odd++;
                prev4 = 1;
            }
        }
        else {
            pos += prev1;
            neg += prev2;
            even += prev3;
            odd += prev4;
        }
    }
    cout << pos << " " << neg << " " << even << " " << odd;
}