Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: nicekrittaphat
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.011 second
Submitted On: 2026-10-13 15:35:15
#include<iostream>
using namespace std;
int main(){
int row,col;
cin>>row>>col;
int matrix[row][col];
int counp=0,counn=0,coune=0,couno=0;
for(int i=0;i<row;i++){
for(int j=0;j<col;j++){
cin>>matrix[i][j];
}
}
int n;
int r;
int c;
cin>>n;
string lastPN = "";//true is pos
string lastEO = "";//true is even
int k=0;
for(int i=0;i<n;i++){
cin>>r>>c;
if((r<1||r>row||c<1||c>col)){
if(lastPN=="true")counp+=1;
else if(lastPN=="false") counn+=1;
if(lastEO == "true")coune+=1;
else if(lastEO == "false") couno+=1;
}
else{
lastEO = "";
lastPN = "";
int usefull = matrix[r-1][c-1];
if(usefull>0){counp+=1;lastPN="true";}
if(usefull<0){counn+=1;lastPN="false";}
if(usefull%2==0){coune+=1;lastEO="true";}
else {couno+=1;lastEO="false";}
}
}
cout<<counp<<" "<<counn<<" "<<coune<<" "<<couno;
}