Submission

Status:

PPPPPPxPPP

Subtask/Task Score:

90/100

Score: 90

User: UNJE0o

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

Language: cpp

Time: 0.010 second

Submitted On: 2026-10-11 19:03:27

#include <bits/stdc++.h>
using namespace std;
#define en '\n'

int main(){
    int ps = 0,ms = 0,od = 0,ve = 0,
        m,n,x,y,l,By,Bx;
    cin >> m >> n;

    int bx[m][n];
    for(int i = 0;i < m;i++){
        for(int j = 0;j < n;j++) cin >> bx[i][j];
    }
    cin >> l;
    for(int i = 0;i < l;i++){
        cin >> y >> x;
        if(y-1>= 0 && y-1 < m && x-1 >= 0 && x-1 < n){
            if(bx[y-1][x-1] > 0) ps += 1;
            if(bx[y-1][x-1] < 0) ms += 1;
            if(bx[y-1][x-1]%2 != 0) od += 1;
            if(bx[y-1][x-1]%2 == 0) ve += 1;
            By = y;
            Bx = x;
        }
        else {
            if(bx[By-1][Bx-1] > 0) ps += 1;
            if(bx[By-1][Bx-1] < 0) ms += 1;
            if(bx[By-1][Bx-1]%2 != 0) od += 1;
            if(bx[By-1][Bx-1]%2 == 0) ve += 1;
        }
    }

    printf("%d %d %d %d",ps,ms,ve,od);

}