Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: pann
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.009 second
Submitted On: 2026-10-11 04:29:04
#include <iostream>
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 n;
cin >> n;
int pos = 0, neg = 0, even = 0, odd = 0;
int xlast, ylast;
bool a = false;
for (int i = 0; i < n; i++) {
int x, y;
cin >> x >> y;
if (x > r || x < 1 || y > c || y < 1) {
if (!a) continue;
x = xlast;
y = ylast;
}
else {
xlast = x;
ylast = y;
a = true;
}
x--;
y--;
if (arr[x][y] > 0) pos++;
if (arr[x][y] < 0) neg++;
if (arr[x][y] % 2 == 0)
even++;
else
odd++;
}
cout << pos << " " << neg << " " << even << " " << odd;
return 0;
}