Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: fillhavertz
Problemset: สำรวจอาเรย์ 1
Language: cpp
Time: 0.005 second
Submitted On: 2025-10-13 12:01:35
#include <iostream>
#include <vector>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int r, c;
cin >> r >> c;
vector<vector<int>> table(r, vector<int>(c));
for (int i = 0; i < r; i++)
for (int j = 0; j < c; j++)
cin >> table[i][j];
int odd = 0, even = 0, plus = 0, minus = 0;
int n;
cin >> n;
vector<pair<int,int>> q(n);
for (int i = 0; i < n; i++)
cin >> q[i].first >> q[i].second;
for (int i = 0; i < n; i++) {
int x = q[i].first - 1;
int y = q[i].second - 1;
if (x >= 0 && x < r && y >= 0 && y < c) {
int val = table[x][y];
if (val > 0) plus++;
else if (val < 0) minus++;
if (val % 2 == 0) even++;
else odd++;
}
}
cout << plus << ' ' << minus << ' ' << even << ' ' << odd;
return 0;
}