Submission
Status:
PPPPPP-PPP
Subtask/Task Score:
90/100
Score: 90
User: porpeang
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.012 second
Submitted On: 2026-10-05 19:57:35
#include <bits/stdc++.h>
using namespace std;
int main(){
int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,k=0,m=0,z=0,x=0;
int arr[1000][1000]={};
cin>>a;
cin>>b;
for(int i=1;i<=a;i++){
for(int j=1;j<=b;j++){
cin>>c;
arr[i][j]=c;
}
}
cin>>d;
for(int t=0;t<d;t++){
cin>>e;
cin>>f;
if(e>=1 && f>=1 && e<=a && f<=b ){
// cout<<'\n'<<arr[e][f];
z=e;
x=f;
if(arr[e][f]>=1){
g++;
}
else if(arr[e][f]<0){
h++;
}
if(arr[e][f]%2==0){
k++;
}
else{
m++;
}
}
else{
if(arr[z][x]>=1){
g++;
}
else if(arr[z][x]<0){
h++;
}
if(arr[z][x]%2==0){
k++;
}
else{
m++;
}
}
}
cout<<g<<" "<<h<<" "<<k<<" "<<m;
}