Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: herespeed
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.011 second
Submitted On: 2026-10-14 13:33:48
#include <bits/stdc++.h>
using namespace std;
struct p{
int r,c;
};
int main(){
int r,c;
cin>>r>>c;
int matrix[r][c];
for(int i=0;i<r;++i){
for(int j=0;j<c;++j){
cin>>matrix[i][j];
}
}
int po =0;
int ne =0;
int even=0;
int odd =0;
int n;
bool evenE=false; bool oddE=false; bool poE=false;
bool neE=false;
cin>>n;
p point;
for(int i=0;i<n;++i){
p temp;
cin>>temp.r>>temp.c;
if(!(temp.r<=r&&temp.r>0&& temp.c<=c&&temp.c>0)) {
if(evenE) even++;
else if(oddE) odd++;
if(poE) po++;
else if(neE) ne++;
continue;
}
evenE=false; oddE=false; poE=false;
neE=false;
temp.r--; temp.c--;
if(matrix[temp.r][temp.c]>0){
po++;
poE = true;
}
else if(matrix[temp.r][temp.c]<0){
ne++;
neE = true;
}
if(matrix[temp.r][temp.c]%2==0){
even++;
evenE = true;
}
else{
odd++;
oddE = true;
}
}
cout<<po<<" "<<ne<<" "<<even<<" "<<odd;
}