Submission

Status:

PPPPPP-PPP

Subtask/Task Score:

90/100

Score: 90

User: pann

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

Language: cpp

Time: 0.009 second

Submitted On: 2026-10-11 04:18:02

#include <iostream>
using namespace std;

int main() {
    int r, c;
    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];
        }
    }
    int n;
    cin >> n;
    int pos = 0, neg = 0, even = 0, odd = 0;
    int xlast = -1, ylast = -1;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        if (x > r || x < 1 || y > c || y < 1) {
            x = xlast;
            y = ylast;
        }
        else {
            xlast = x;
            ylast = y;
        }
        x--;
        y--;
        if (arr[x][y] > 0) pos++;
        if (arr[x][y] < 0) neg++;
        if (arr[x][y] % 2 == 0)
            even++;
        else
            odd++;
    }
    cout << pos << " " << neg << " " << even << " " << odd;
    return 0;
}