Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: Some1258
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.009 second
Submitted On: 2026-07-24 08:28:49
#include <iostream>
#include <vector>
using namespace std;
int main() {
int x, y;
cin >> x >> y;
vector<vector<int>> arr(x, vector<int>(y));
for (int i = 0; i < x; i++) {
for (int j = 0; j < y; j++) {
cin >> arr[i][j];
}
}
int num;
cin >> num;
int temp;
bool hasPrevious = false;
int ans[4] = {0};
for (int i = 0; i < num; i++) {
int a, b;
cin >> a >> b;
a--;
b--;
if (a < 0 || a >= x || b < 0 || b >= y) {
if (!hasPrevious) {
continue;
}
} else {
temp = arr[a][b];
hasPrevious = true;
}
if (temp % 2 == 0) {
ans[2]++;
} else {
ans[3]++;
}
if (temp > 0) {
ans[0]++;
} else if (temp < 0) {
ans[1]++;
}
}
for (int i = 0; i < 4; i++) {
cout << ans[i] << " ";
}
return 0;
}