Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: onlyme910
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.009 second
Submitted On: 2025-10-08 17:01:42
#include <bits/stdc++.h>
using namespace std;
int R,C;
int last[4];
int main(){
int plus = 0,minus = 0,even = 0,odd = 0;
cin >> R >> C;
int arr[R][C];
for(int i = 0;i<R;i++){
for(int j = 0;j<C;j++){
cin >> arr[i][j];
}
}
int K,x,y;
cin >> K;
while(K--){
cin >> x >> y;
if(x <1 || y<1||x>R||y>C){
for(int i = 0;i < 4;i++){
switch (i)
{
case 0:
plus += last[i];
break;
case 1:
minus += last[i];
break;
case 2:
even += last[i];
break;
case 3:
odd += last[i];
break;
}
}
continue;
}
for(int t = 0;t<4;t++){
last[t] = 0;
}
x--;y--;
if(arr[x][y] < 0){
minus++;
last[1] = 1;
}
if(arr[x][y] > 0){
plus++;
last[0] = 1;
}
if(arr[x][y]%2 == 0){
even++;
last[2] = 1;
}
else {
odd++;
last[3] = 1;
}
}
cout << plus << " " << minus << " " << even << " " << odd;
}