Submission
Status:
PPPPPP-PPP
Subtask/Task Score:
90/100
Score: 90
User: code
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.009 second
Submitted On: 2026-04-17 12:13:41
#include <bits/stdc++.h>
using namespace std;
int main (){
int r,c;cin>>r>>c;
int arr[r][c]={0};
for (int i=0;i<r;i++){
for (int j=0;j<c;j++){
cin>>arr[i][j];
}
}
int k;cin>>k;
int pos=0,neg=0,even=0,odd=0,a=0,b=0;
for (int i=0;i<k;i++){
int x,y;cin>>x>>y;
x--;y--;
if (i==0){a=x;b=y;}
if (x<0 || x>=r || y<0 || y>=c){
if (arr[a][b]>0){
pos++;
}else if (arr[a][b]<0){
neg++;
}if (arr[a][b]%2==0){
even++;
}else{
odd++;
}
}else{
if (arr[x][y]>0){
pos++;
}else if (arr[x][y]<0){
neg++;
}if (arr[x][y]%2==0){
even++;
}else{
odd++;
}
a=x;b=y;
}
}
cout<<pos<<" "<<neg<<" "<<even<<" "<<odd;
return 0;
}