Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: Prap
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.009 second
Submitted On: 2026-03-25 12:37:34
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
using namespace std;
int main() {
int R,C;
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];
}
}
int K;
cin>>K;
int aa,bb;
int countodd = 0;
int counteven = 0;
int countpos = 0;
int countnig = 0;
int odd = 0;
int nig = 0;
int pos = 0;
int even = 0;
for (int i = 0; i<K; i++) {
cin>>aa>>bb;
if (aa>0 && bb>0 && aa<=R && bb<=C) {
if (arr[aa-1][bb-1] < 0) {
countnig++;
nig = 1;
}
else {
nig = 0;
}
if (arr[aa-1][bb-1] > 0) {
countpos++;
pos = 1;
}
else {
pos = 0;
}
if (arr[aa-1][bb-1] % 2 == 0) {
counteven++;
even = 1;
}
else {
even = 0;
}
if (arr[aa-1][bb-1] % 2 == 1 || arr[aa-1][bb-1] % 2 == -1) {
countodd++;
odd = 1;
}
else {
odd = 0;
}
}
else {
countodd = countodd + odd;
countpos+=pos;
countnig+=nig;
counteven+=even;
}
}
cout<<countpos<<" "<<countnig<<" "<<counteven<<" "<<countodd;
return 0;
return 0;
}