Submission
Status:
PPPPPPxPPP
Subtask/Task Score:
90/100
Score: 90
User: Some1258
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.009 second
Submitted On: 2026-05-06 17:44:22
#include<iostream>
using namespace std;
int main(){
int x,y;
cin>>x>>y;
int arr[x][y];
for(int i=0;i<x;i++){
for(int j=0;j<y;j++){
cin>>arr[i][j];
}
}
int num;
cin>>num;
int ans[4]={0};
int temp[2];
for(int i=0;i<num;i++){
int a,b;
cin>>a>>b;
a--;
b--;
if(a<0||a>=x||b<0||b>=y){
a=temp[0];
b=temp[1];
}
int z=arr[a][b];
if(z%2==0){
ans[2]++;
}else{
ans[3]++;
}
if(z>0){
ans[0]++;
}else if(z<0){
ans[1]++;
}
temp[0]=a;
temp[1]=b;
}
for(int i=0;i<4;i++){
cout<<ans[i]<<" ";
}
}