Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: 666whynot
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.005 second
Submitted On: 2025-10-04 12:37:14
#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);cin.tie(nullptr);
int n,m;cin >> n >> m;
int a[n][m] = {};
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin >> a[i][j];
}
}
int plus=0,nega=0,even=0,odd=0;
int qw;cin >> qw;
bool plus1=false,nega1=false,even1=false,odd1=false;
while(qw--){
int x,y;cin >> x >> y;
x--,y--;
if(x >= 0 && x<n && y>=0 && y < m){
plus1=nega1=even1=odd1=false;
if(a[x][y] % 2 == 0){even++;even1 = true;}
if(a[x][y] > 0) {plus++;plus1 = true;}
if(a[x][y] <0) {nega++;nega1=true;}
if(a[x][y] % 2 != 0){odd++;odd1 =true;}
}
else{
if(plus1)plus++;
if(nega1)nega++;
if(even1)even++;
if(odd1)odd++;
}
if(qw == 0)cout << plus << ' ' << nega << ' ' << even << ' '<< odd << '\n';
}
}