Submission
Status:
PPPPPP-PPP
Subtask/Task Score:
90/100
Score: 90
User: kinzap
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.009 second
Submitted On: 2025-10-13 00:36:42
#include <iostream>
using namespace std;
int r,c,a,n,pos,neg,odd,eve,x,y,o;
int main(){
cin >> r >>c ;
int arr[r][c];
for(int i =0;i<r;i++){
for(int j =0;j<c;j++){
cin >> a;
arr[i][j]=a;
}
}
cin >> n;
for(int i = 0;i<n;i++){
cin >> x >> y;
//cout << "x " <<x<<" y "<<y <<" arr " <<arr[x-1][y-1] << endl;
if(x-1 < 0 || y-1 < 0 || x-1 >= r || y-1 >= c){
if(o>0)pos++;
if(o<0)neg++;
if(o %2==0)eve++;
if(o %2== 1 || o%2== -1 )odd++;
}
else {
if(arr[x-1][y-1]>0)pos++;
if(arr[x-1][y-1]<0)neg++;
if(arr[x-1][y-1] %2==0)eve++;
if(arr[x-1][y-1] %2== 1 || arr[x-1][y-1] %2== -1 )odd++;
o=arr[x-1][y-1];
}
}
cout << pos << " " << neg << " " << eve << " " << odd;
}