Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: ztmy_
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.009 second
Submitted On: 2025-10-12 17:01:26
#include <iostream>
using namespace std;
int main(){
int r, c;
int plus = 0, minus = 0, even = 0, odd = 0;
cin >> r >> c;
int arr[r+1][c+1] = {0};
for (int i = 1; i <= r; i++){
for (int j = 1; j <= c; j++){
cin >> arr[i][j];
}
}
int k;
int x, y, xtemp = 0, ytemp = 0;
cin >> k;
for (int i = 1; i <= k; i++){
cin >> x >> y;
if (x <= 0 || x > r || y <= 0 || y > c){
x = xtemp;
y = ytemp;
}
if (x > 0 && x <= r && y > 0 && y <= c){
if (arr[x][y] % 2 == 0) {
even++;
xtemp = x;
ytemp = y;
}
if (arr[x][y] % 2 != 0) {
odd++;
xtemp = x;
ytemp = y;
}
if (arr[x][y] > 0) {
plus++;
xtemp = x;
ytemp = y;
}
if (arr[x][y] < 0) {
minus++;
xtemp = x;
ytemp = y;
}
}
}
cout << plus << " " << minus << " " << even << " " << odd;
}