Submission
Status:
PPPPPPPPPP
Score: 100
User: Pera
Problemset: สำรวจอาเรย์ 1
Language: cpp
Time: 0.005 second
Submitted On: 2025-05-18 17:07:03
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
int rSize, cSize;
cin >> rSize >> cSize;
vector<vector<int>> grid(rSize, vector<int>(cSize));
for (int i = 0; i < rSize; ++i) {
for (int j = 0; j < cSize; ++j) {
cin >> grid[i][j];
}
}
int n; cin >> n;
int posCount{0};
int negCount{0};
int evenCount{0};
int oddCount{0};
for (int i = 0; i < n; ++i) {
int x, y; cin >> x >> y;
if (x >= 1 && x <= rSize && y >= 1 && y <= cSize) {
if (grid[x-1][y-1] > 0) {
posCount++;
} else if (grid[x-1][y-1] < 0) negCount++;
if (grid[x-1][y-1] % 2 == 0) evenCount++;
else oddCount++;
}
}
cout << posCount << ' ' << negCount << ' ' << evenCount << ' ' << oddCount << '\n';
}