Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: matcherbrainner
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.009 second
Submitted On: 2026-10-31 22:00:50
#include<bits/stdc++.h>
using namespace std;
int main(){
int R,C;
cin>>R>>C;
vector<vector<long long>>a(R,vector<long long>(C));
for(int i=0;i<R;i++){
for(int j=0;j<C;j++){
cin>>a[i][j];
}
}
int K;
cin>>K;
int pos=0,neg=0,even=0,odd=0;
int lp=0,lng=0,lev=0,lod=0;
bool hv=false;
for(int k=0;k<K;k++){
int r,c;
cin>>r>>c;
if(r>=1&&r<=R&&c>=1&&c<=C){
long long val=a[r-1][c-1];
lp=0;lng=0;lev=0;lod=0;
if(val>0){
pos++;
lp=1;
}
else if(val<0){
neg++;
lng=
1;
}
if((val/2)*2==val){
even++;
lev=1;
}
else{
odd++;
lod=1;
}
hv=true;
}
else{
if(hv){
pos+=lp;
neg+=lng;
even+=lev;
odd+=lod;
}
}
}
cout<<pos<<" "<<neg<<" "<<even<<" "<<odd<<" ";
}