Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: Folk_DIWA
Problemset: สำรวจอาเรย์ 1
Language: cpp
Time: 0.006 second
Submitted On: 2026-10-13 01:32:09
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
cin.tie(0)->sync_with_stdio(0);
int r,c; cin >> r >> c;
vector <vector<int>> v(r, vector<int>(c));
vector <pair <int,int>> p;
for(int i=0; i<r; i++){
for(int j=0; j<c; j++){
cin >> v[i][j];
}
}
// for(int i=0; i<r; i++){
// for(int j=0; j<c; j++){
// cout << v[i][j] << ' ';
// }
// }
int k; cin >> k;
for(int i=0; i<k; i++){
int x,y; cin >> x >> y;
if(x <= 0 or x > r) continue;
if(y <= 0 or y > c) continue;
p.push_back({x-1, y-1});
}
int pos=0,neg=0,even=0,odd=0;
for(int i=0; i<p.size(); i++){
if(v[p[i].first][p[i].second]%2 == 0) even++;
else odd++;
if(v[p[i].first][p[i].second] > 0) pos++;
else if(v[p[i].first][p[i].second] < 0) neg++;
}
cout << pos << ' ' << neg << ' ' << even << ' ' << odd;
return 0;
}