Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: MoZkun
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.009 second
Submitted On: 2025-09-30 09:46:32
#include<bits/stdc++.h>
using namespace std;
#include <iostream>
using namespace std;
int main() {
int r, c;
while (cin >> r >> c) {
int a[305][305];
for (int i = 1; i <= r; i++) {
for (int j = 1; j <= c; j++) {
cin >> a[i][j];
}
}
int k;
cin >> k;
int pos = 0, neg = 0, even = 0, odd = 0;
int hasLast = 0;
int lastVal = 0;
for (int i = 0; i < k; i++) {
int x, y;
cin >> x >> y;
if (x >= 1 && x <= r && y >= 1 && y <= c) {
lastVal = a[x][y];
hasLast = 1;
}
if (hasLast) {
if (lastVal > 0) pos++;
if (lastVal < 0) neg++;
if (lastVal % 2 == 0) even++;
else odd++;
}
}
cout << pos << " " << neg << " " << even << " " << odd << "\n";
}
return 0;
}