Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: Sense.exe
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.006 second
Submitted On: 2026-10-07 18:52:19
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int rows, cols, n;
if (!(cin >> rows >> cols)) return 0;
vector<vector<int>> v(rows, vector<int>(cols));
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
cin >> v[i][j];
}
}
cin >> n;
int x, y;
int tx = -1, ty = -1;
int plus = 0, minus = 0, even = 0, odd = 0;
for (int i = 0; i < n; i++) {
cin >> x >> y;
// เช็คว่าพิกัดอยู่ในตารางหรือไม่ (1-based index)
if (x >= 1 && x <= rows && y >= 1 && y <= cols) {
tx = x;
ty = y;
}
// ถ้าเคยมีพิกัดที่ถูกต้อง (tx, ty ถูกอัปเดตแล้ว)
if (tx != -1 && ty != -1) {
int val = v[tx - 1][ty - 1];
if (val > 0) {
plus++;
} else if (val < 0) {
minus++;
}
if (val % 2 == 0) {
even++;
} else {
odd++;
}
}
}
// พิมพ์แบบไม่มี space ต่อท้ายตัวสุดท้าย
cout << plus << " " << minus << " " << even << " " << odd << "\n";
return 0;
}