Submission
Status:
P---------
Subtask/Task Score:
10/100
Score: 10
User: NovemNotes
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.005 second
Submitted On: 2025-10-15 13:43:22
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
int n,m;cin >> n >> m;
vector<vector<int>> v(n+1,vector<int>(m+1,0));
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin >> v[i][j];
}
}
int a,b,c,d;
a=b=c=d=0;
int q;cin >> q;
int last=0;
while(q--){
int x,y;cin >> x >> y;
if(x<1||x>n||y<1||y>m){
if(last>0){
a++;
}else if(last<0){
b++;
}
if(last&1){
d++;
}else if(last!=0){
c++;
}
continue;
}
last=v[x][y];
if(v[x][y]>0){
a++;
}else if(v[x][y]<0){
b++;
}
if(v[x][y]&1){
d++;
}else if(v[x][y]!=0){
c++;
}
}
cout << a << " " << b << " " << c << " " << d << "\n";
return 0;
}