Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: Nuttykub
Problemset: สำรวจอาเรย์ 1
Language: cpp
Time: 0.005 second
Submitted On: 2026-10-01 18:29:01
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int m,n;
cin>> m >> n;
int matrix[m][n];
for (int i = 0;i < m;i++){
for (int j = 0;j<n;j++){
cin >> matrix[i][j];
}
}
int q;
cin >> q;
vector<int> gather;
for (int i = 0;i < q;i++){
int a,b;
cin >> a>> b;
if (a < 1 or b < 1 or a > m or b > n) continue;
gather.push_back(matrix[a-1][b-1]);
}
vector<int> ans(4,0);
for (int i = 0;i < gather.size();i++){
if (gather[i] > 0){
if (gather[i]%2 == 0) ans[2]++;
else ans[3]++;
ans[0]++;
}
else if (gather[i] < 0){
if (abs(gather[i])%2 == 0) ans[2]++;
else ans[3]++;
ans[1]++;
}
else ans[2]++;
}
for (auto p : ans) cout << p << " ";
}