Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: shurye
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.010 second
Submitted On: 2026-10-12 22:38:13
#include <iostream>
#include <vector>
using namespace std ;
int r,c,N,Positive,Negative,Even,Odd,lastR,lastC;
vector <int> position ;
int main(){
cin >> r >> c;
int arr[r][c];
for(int i= 0; i < r ; i++){
for(int j = 0 ; j<c ; j++){
cin >> arr[i][j];
}
}
cin >> N;
for(int i = 0; i < N;i++){
int R,C;
cin >> R >> C;
if(!(R <= 0 || R>r || C >c || C <= 0)){
R--; C-- ;
if(arr[R][C] < 0){Negative ++;}
else if(arr[R][C] > 0){Positive++;}
if(arr[R][C] %2 == 0){Even++;}
else {Odd++;}
lastR = R ; lastC = C;
}else if(Positive==0 && Negative== 0 && Even ==0&& Odd==0){
continue;
}
else{
if(arr[lastR][lastC] < 0){Negative ++;}
else if(arr[lastR][lastC] > 0){Positive++;}
if(arr[lastR][lastC] %2 == 0){Even++;}
else {Odd++;}
}
}cout << Positive<< " "<<Negative<< " "<< Even << " "<< Odd;
}