Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: kakcode

Problemset: สำรวจอาเรย์ 2

Language: cpp

Time: 0.008 second

Submitted On: 2025-12-03 23:40:12

/*
TASK: 
LANG: C++
AUTHOR: ICE
*/
#include <bits/stdc++.h>
using ll = long long;
#define forr(i, a, n) for (int i = a; i < n; i++)
const ll inf = 10e9;
#define int ll
using namespace std;
using pii = pair<int,int>;
int arr[310][310];
int ans[4];
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin >> n >> m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++)cin >> arr[i][j];
    }
    int q;
    cin >> q;
    vector<int> last = {0,0,0,0};
    for(int i=0;i<q;i++){
        int y,x;
        cin >> y >> x;
        y--;x--;
        if(y >= n || x  >= m || y < 0 || x < 0){
            for(int i=0;i<4;i++){
                if(last[i])ans[i]++;
            }
        }
        else{
            vector<int> news = {0,0,0,0};
            if(arr[y][x] > 0){ans[0]++;news[0]++;}
            if(arr[y][x] < 0){ans[1]++;news[1]++;}
            if(abs(arr[y][x]) % 2 == 0){ans[2]++;news[2]++;}
            else {ans[3]++;news[3]++;}
            last = news;
        }
        
    }
    for(int i=0;i<4;i++)cout << ans[i] << ' ';
    return 0;
}