Submission
Status:
PPPPPPxPPP
Subtask/Task Score:
90/100
Score: 90
User: ssens3
Problemset: สำรวจอาเรย์ 2
Language: cpp
Time: 0.009 second
Submitted On: 2026-10-04 09:06:19
#include <iostream>
#include <vector>
using namespace std;
int main(){
int r, c, n, x, y, ox, oy, e[4] = {0}; cin >> r >> c;
vector<vector<int>> v(r+1, vector<int>(c+1));
for (int i = 1; i <= r; i++){
for (int j = 1; j <= c; j++){
cin >> v[i][j];
}
}
cin >> n;
for (int i = 0; i < n; i++){
cin >> x >> y;
if (x > r || x <= 0 || y > c || y <= 0){
if (v[ox][oy] > 0) e[0]++;
else if (v[ox][oy] < 0) e[1]++;
if (v[ox][oy] % 2 == 0) e[2]++;
else e[3]++;
continue;
}
if (v[x][y] > 0) e[0]++;
else if (v[x][y] < 0) e[1]++;
if (v[x][y] % 2 == 0) e[2]++;
else e[3]++;
ox = x; oy = y;
}
for (int i = 0; i < 4; i++){
cout << e[i] << " ";
}
}