Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: lingusso
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.009 second
Submitted On: 2026-03-25 13:03:45
#include<iostream>
#include<string>
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 n,x,y,p=0,N=0,e=0,o=0;
int pos=0,neg=0,odd=0,even=0;
cin>>n;
for(int i=1;i<=n;i++){
cin>>x>>y;
if(x > r || y >c || x<=0 || y<=0){
pos += p;
neg +=N;
even +=e;
odd +=o;
continue;
}
if(arr[x-1][y-1] == 0){
p =0;
N =0;
}
else if(arr[x-1][y-1] > 0){
pos++;
p =1;
N =0;
}
else{
neg++;
N =1;
p =0;
}
if(arr[x-1][y-1] % 2 ==0){
even++;
e =1;
o =0;
}
else{
odd++;
o =1;
e =0;
}
}
cout<<pos<<" "<<neg<<" "<<even<<" "<<odd<<" "<<"\n";
return 0;
}