Submission
Status:
----------
Subtask/Task Score:
0/100
Score: 0
User: onlyme910
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.009 second
Submitted On: 2025-10-08 16:54:21
#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[0];
break;
case 1:
minus += last[1];
break;
case 2:
minus += last[2];
break;
case 3:
minus += last[3];
break;
}
}
}
else{
x--;y--;
if(arr[x][y] < 0){
minus++;
last[1] = 1;
}else last[1] = 0;
if(arr[x][y] > 0){
plus++;
last[0] = 1;
}else last[0] = 0;
if(arr[x][y]%2 == 0){
even++;
last[2] = 1;
}else last[2] = 0;
if(arr[x][y]%2 != 0){
odd++;
last[3] = 1;
}else last[3] = 0;
}
}
cout << plus << " " << minus << " " << even << " " << odd;
}