Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: Songkran

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

Language: cpp

Time: 0.009 second

Submitted On: 2025-09-27 22:35:03

#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++;
            if (io) odd++;
            continue;
        }
    
    
        ip = im = ie = 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;
}