Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: cheetah

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

Language: cpp

Time: 0.005 second

Submitted On: 2026-06-03 15:34:05

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

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

    int r, c;
    cin >> r >> c;

    int ar[305][305];

    for (int i = 1; i <= r; ++i) {
        for (int j = 1; j <= c; ++j) {
            cin >> ar[i][j];
        }
    }

    int k;
    cin >> k;

    int pos = 0, neg = 0, even = 0, odd = 0;

    for (int i = 0; i < k; ++i) {
        int x, y;
        cin >> x >> y;

        if (x >= 1 && x <= r && y >= 1 && y <= c) {
            int num = ar[x][y];

            if (num > 0) {
                ++pos;
            }
            else if (num < 0) {
                ++neg;
            }

            if (num % 2 == 0) {
                ++even;
            }
            else {
                ++odd;
            }
        }
    }

    cout << pos << " " << neg << " " << even << " " << odd;

    return 0;
}