Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: colo39
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.006 second
Submitted On: 2026-10-01 14:25:13
#include <bits/stdc++.h>
using namespace std;
int arr[400][400];
int a,b,c,d;
int la,lb,lc,ld;
int main () {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n,m;
cin >> n >> m;
for (int i = 1;i <= n;i++) {
for (int j =1;j <= m;j++) {
cin >> arr[i][j];
}
}
int q;
cin >> q;
// มีจ ำนวนเลขบวก จ ำนวนเลขติดลบ จ ำนวนคู่ และ จ ำนวนค
while (q--) {
int x,y;
cin >> x >> y;
if (x < 1 || x > n || y < 1 || y > m) {
a +=la;
b+=lb;
c+=lc;
d+=ld;
continue;
}
int num = arr[x][y];
if (num > 0){a++;la = 1;}
else {la=0;}
if (num < 0){b++;lb =1;}
else {lb = 0;}
if (num % 2 == 0){c++;lc=1;ld=0;}
else {d++;ld=1;lc=0;}
}
cout << a << " " << b << " " << c << " " << d;
}