Submission
Status:
PPPPPPxPPP
Subtask/Task Score:
90/100
Score: 90
User: Tjeez
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.009 second
Submitted On: 2026-10-09 00:37:35
#include <iostream>
using namespace std;
int main(){
int r,c; 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; cin>>k;
int lx,ly;
int p=0,n=0,e=0,o=0;
for (int i=0 ; i<k ; i++){
int x,y; cin>>x>>y;
if (x>=1 && x<=r && y>=1 && y<=c){
x--;y--;
lx=x; ly=y;
if (arr[x][y]%2==0)e++;
else o++;
if (arr[x][y]>0) p++;
else if(arr[x][y]<0) n++;
}
else{
if (arr[lx][ly]%2==0)e++;
else o++;
if (arr[lx][ly]>0) p++;
else if(arr[lx][ly]<0) n++;
}
}
cout<<p<<" "<<n<<" "<<e<<" "<<o;
}
/*4 6 0 -1 2 3 -3 -7 11 7 -4 12 17 -6 -7 12 11 -9 -1 0 0 -2 8 10 -5 8 10 4 2 1 1 -3 2 2 0 3 4 2 6 1 4 4 5 3 7 5 2 */