Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: Alif_Sama

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

Language: cpp

Time: 0.009 second

Submitted On: 2025-10-07 21:25:06

#include <iostream>
using namespace std;

int main() {
    int n,m;
    cin >> n >> m;
    int arr[n][m] = {0};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> arr[i][j];
        }
    }
    //just print array debug test heh
    // for (int i = 0; i < n; i++) {
    //     for (int j = 0; j < m; j++) {
    //         cout << arr[i][j] << " ";
    //     }
    //     cout << "\n";
    // }
    int s;
    cin >> s;
    int minus = 0,plus = 0,even = 0,odd = 0;
    for (int i = 0; i < s; i++) {
        int a,b;
        cin >> a >> b;
        if (a-1 >= 0 && a-1 <= n-1 && b-1 >= 0 && b-1 <= m-1) {
            int num = arr[a-1][b-1];
            // cout << "\n" << num << "\n";
            if (num == 0) {
                even++;
                continue;
            } else if (num > 0 && num % 2 == 0) {
                plus++;
                even++;
            } else if (num > 0 && num % 2 == 1) {
                plus++;
                odd++;
            } else if (num < 0 && abs(num) % 2 == 0) {
                minus++;
                even++;
            } else if (num < 0 && abs(num) % 2 == 1) {
                minus++;
                odd++;
            }
        }
    }
    printf("%d %d %d %d", plus,minus,even,odd);
}