Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: Bestzu
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.005 second
Submitted On: 2025-10-15 13:55:02
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int r, c; cin >> r >> c;
vector<vector<int>> a(r+1, vector<int>(c+1));
for(int i = 1; i <= r; i++) {
for(int j = 1; j <= c; j++) {
cin >> a[i][j];
}
}
int even = 0, odd = 0, pos = 0, neg = 0;
int prev;
bool first_in_array = false;
int q; cin >> q;
while(q--) {
int i, j; cin >> i >> j;
int val;
if(i >= 1 && i <= r && j >= 1 && j <= c) {
first_in_array = true;
val = a[i][j];
prev = val;
} else {
if(!first_in_array) continue;
val = prev;
}
if(val % 2 == 0) even++;
else odd++;
if(val > 0) pos++;
else if(val < 0) neg++;
}
cout << pos << " " << neg << " " << even << " " << odd;
return 0;
}