Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: UNJE0o
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.009 second
Submitted On: 2026-10-11 19:07:06
#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(i > 0){
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);
}