Submission
Status:
PPPPPPxPPP
Subtask/Task Score:
90/100
Score: 90
User: Sense.exe
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.005 second
Submitted On: 2026-10-07 18:54:22
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int rows,cols,n;
cin >> rows >> cols;
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,tx=-1,ty=-1;
int plus=0,minus=0,even=0,odd=0;
for(int i=0; i<n; i++) {
cin >> x >> y;
if(x>0&&x<=rows && y>0&&y<=cols) {
tx = x;
ty = y;
if (tx != -1 && ty != -1) {
if(v[x-1][y-1]>0) {
plus++;
// cout << v[x-1][y-1] << plus <<" ";
}
else if(v[x-1][y-1]<0){
minus++;
// cout << v[x-1][y-1] << minus <<" ";
}
if(v[x-1][y-1]%2==0) {
even++;
// cout << v[x-1][y-1] << even <<" ";
}
else {
odd++;
// cout << v[x-1][y-1] << odd <<" ";
}
}
}
else {
if(v[tx-1][ty-1]>0) {
plus++;
// cout << v[x-1][y-1] << plus <<" ";
}
else if(v[tx-1][ty-1]<0){
minus++;
// cout << v[x-1][y-1] << minus <<" ";
}
if(v[tx-1][ty-1]%2==0) {
even++;
// cout << v[x-1][y-1] << even <<" ";
}
else {
odd++;
// cout << v[x-1][y-1] << odd <<" ";
}
}
}
cout << plus << " " << minus << " " << even << " " << odd;
}