Submission
Status:
PPPPPPxPPP
Subtask/Task Score:
90/100
Score: 90
User: dy
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.012 second
Submitted On: 2026-10-03 19:39:58
#include<bits/stdc++.h>
using namespace std;
int a[304][304];
int main(){
int n,y,x,x1,y1,r,c,even=0,odd=0,p=0,mn=0,kk;
cin>>r>>c;
for(int i=1;i<=r;i++){
for(int j=1;j<=c;j++){
cin>>a[i][j];
}
}
cin>>n;
for(int i=0;i<n;i++){
cin>>y>>x;
if(y>r||x>c||y<=0||x<=0){
if(a[y1][x1]>0){
p++;
}
if(a[y1][x1]<0){
mn++;
}
if(a[y1][x1]%2==0){
even++;
}
else{
odd++;
}
continue;
}
if(a[y][x]>0){
p++;
x1=x;
y1=y;
}
if(a[y][x]<0){
mn++;
x1=x;
y1=y;
}
if(a[y][x]%2==0){
even++;
x1=x;
y1=y;
}
else{
odd++;
x1=x;
y1=y;
}
}
cout<<p<<" "<<mn<<" "<<even<<" "<<odd;
}