Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: TonnamSora
Problemset: สำรวจอาเรย์ 1
Language: cpp
Time: 0.009 second
Submitted On: 2025-10-07 13:54:11
#include <iostream>
#include <cmath>
using namespace std;
int main(){
int y, x;
cin >> y >> x;
int a[y][x];
for(int i = 0; i < y; i++){
for(int j = 0; j < x; j++){
cin >> a[i][j];
}
}
int N;
cin >> N;
int q[N], p[N];
for(int i = 0; i < N; i++){
cin >> q[i] >> p[i];
}
int pos = 0, neg = 0, even = 0, odd = 0;
int f;
for(int i = 0; i < N; i++){
p[i]--;
q[i]--;
if (p[i] < 0 || p[i] >= x || q[i] < 0 || q[i] >= y){
continue;
}
f = a[q[i]][p[i]];
if(f < 0){
neg++;
}
if(f > 0){
pos++;
}
if(f % 2 == 0){
even++;
}
if(abs(f) % 2 == 1){
odd++;
}
}
cout << pos << " " << neg << " " << even << " " << odd;
}