Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: Nuttykub
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.007 second
Submitted On: 2026-10-02 10:33:58
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int m, n;
cin >> m >> n;
vector<vector<int>> matrix(m, vector<int>(n));
for (auto &row : matrix)
for (auto &x : row) cin >> x;
int q;
cin >> q;
bool hasLast = false;
int last = 0;
int pos = 0, neg = 0, even = 0, odd = 0;
while (q--) {
int a, b;
cin >> a >> b;
if (a >= 1 && a <= m && b >= 1 && b <= n) {
last = matrix[a - 1][b - 1];
hasLast = true;
}
if (!hasLast) continue; // nothing to repeat yet
if (last > 0) pos++;
else if (last < 0) neg++;
if (last % 2 == 0) even++;
else odd++;
}
cout << pos << " " << neg << " " << even << " " << odd << "\n";
}