Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: chokun
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.011 second
Submitted On: 2026-10-13 08:25:30
#include <bits/stdc++.h>
using namespace std;
int main(){
int r, c;
cin >> r >> c;
int a[r][c];
int count_positive_int = 0;
int count_negative_int = 0;
int count_even = 0;
int count_odd = 0;
int last_pos = 0;
int last_neg = 0;
int last_even = 0;
int last_odd = 0;
for (int i = 0; i < r; i++){
for (int j = 0; j < c; j++){
cin >> a[i][j];
}
}
int n;
cin >> n;
for (int i = 0; i < n; i++){
int row, col;
cin >> row >> col;
if (row >= 1 && row <= r && col >= 1 && col <= c) {
int val = a[row - 1][col - 1];
last_pos = 0;
last_neg = 0;
last_even = 0;
last_odd = 0;
if (val > 0) last_pos = 1;
else if (val < 0) last_neg = 1;
if (val % 2 == 0) last_even = 1;
else last_odd = 1;
}
count_positive_int += last_pos;
count_negative_int += last_neg;
count_even += last_even;
count_odd += last_odd;
}
cout << count_positive_int << " " << count_negative_int << " " << count_even << " " << count_odd << "\n";
}