Submission
Status:
PPPPPPxPPP
Subtask/Task Score:
90/100
Score: 90
User: ChanakanStudy
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.005 second
Submitted On: 2026-10-09 15:50:33
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
using namespace std;
using ll = long long;
int a[301][301];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,m;
cin >> n >> m;
for(int i = 0;i<n;i++) {
for(int j = 0;j<m;j++) {
int temp;
cin >> temp;
a[i][j] = temp;
}
}
int countplus = 0,countera = 0,counteven=0,countodd=0 , rememberx , remembery;
int q;
cin >> q;
while(q--) {
int x,y;
cin >> x >> y;
if((x <= n && y <= m) && (x > 0 && y > 0)) {
x--;
y--;
if(a[x][y] >0) {
countplus++;
}
if(a[x][y]< 0) {
countera++;
}
if(a[x][y] %2 == 0) {
counteven++;
}
else {
countodd++;
}
rememberx = x;
remembery = y;
}
else {
if(a[rememberx][remembery] >0) {
countplus++;
}
if(a[rememberx][remembery]< 0) {
countera++;
}
if(a[rememberx][remembery] %2 == 0) {
counteven++;
}
else {
countodd++;
}
}
}
cout << countplus << " " << countera << " " << counteven << " " << countodd;
return 0;
}