Submission
Status:
PP-PPP-PP-
Subtask/Task Score:
70/100
Score: 70
User: nicekrittaphat
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.009 second
Submitted On: 2026-10-13 15:16:58
#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;
bool lastPN = true;//true is pos
bool lastEO = true;//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)&&k!=0){
if(lastPN)counp+=1;
else counn+=1;
if(lastEO)coune+=1;
else couno+=1;
}
else{
int usefull = matrix[r-1][c-1];
if(usefull>0){counp+=1;k+=1;lastPN=true;}
if(usefull<0){counn+=1;k+=1;lastPN=false;}
if(usefull%2==0){coune+=1;k+=1;lastEO=true;}
else {couno+=1;k+=1;lastEO=false;}
}
}
cout<<counp<<" "<<counn<<" "<<coune<<" "<<couno;
}