Submission

Status:

PPPPPP-PPP

Subtask/Task Score:

90/100

Score: 90

User: Songkran

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

Language: cpp

Time: 0.010 second

Submitted On: 2025-09-27 22:27:52

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

int main(){
    int m,n,find,plus = 0,minus = 0,even = 0,odd =0;
    bool ip=0,im=0,ie=0,io=0;
    cin >> m >>n;
    int arr[m][n];
    for (int i = 0; i < m; i++){
        for (int j = 0; j < n; j++){
            cin >> arr[i][j];
        }
    }
    cin >> find;
    int it[find], jt[find];
    for (int x = 0; x < find; x++){
        cin >> it[x] >> jt[x];
        int row = it[x] - 1;
        int col = jt[x] - 1;
        if (row < 0 || row >= m || col < 0 || col >= n){
            if (ip){ 
            plus++;
        }
            if (im){ 
            minus++;
        }
            if (ie){
            even++;
        }
            else {
            odd++;
        }
            continue;
        }
        ip = false;
        im = false;
        ie = false;
        io = false;
        if (arr[row][col] > 0){ 
            plus++;
            ip = true;
        }
        if (arr[row][col] < 0){ 
            minus++;
            im = true;
        }
        if (arr[row][col] % 2 == 0){
            even++;
            ie = true;
        }
        else {
            odd++;
            io = true;
        }
    }

    cout << plus << " " << minus << " " << even << " " << odd;
    return 0;
}