Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: loop
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.012 second
Submitted On: 2026-10-10 18:43:34
#include <iostream>
using namespace std;
int g[305][305];
// A coordinate outside the table counts the previous round's value again. The statement says the first coordinate
// is always inside, but one of gchan's tests starts outside: nothing is counted until the first one inside.
int main() {
int R, C, K;
cin >> R >> C;
for (int i = 1; i <= R; i++)
for (int j = 1; j <= C; j++) cin >> g[i][j];
cin >> K;
int pos = 0, neg = 0, even = 0, odd = 0, last = 0;
bool have = false;
for (int k = 0; k < K; k++) {
int r, c;
cin >> r >> c;
int v = last;
if (r >= 1 && r <= R && c >= 1 && c <= C) { v = g[r][c]; have = true; }
if (!have) continue;
last = v;
if (v > 0) pos++;
if (v < 0) neg++;
if (v % 2 == 0) even++; else odd++;
}
cout << pos << ' ' << neg << ' ' << even << ' ' << odd << '\n';
return 0;
}