Submission

Status:

PPPPPP-PPP

Subtask/Task Score:

90/100

Score: 90

User: NovemNotes

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

Language: cpp

Time: 0.006 second

Submitted On: 2025-10-15 13:46:57

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,m;cin >> n >> m;
    vector<vector<int>> v(n+1,vector<int>(m+1,0));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin >> v[i][j];
        }
    }
    int a,b,c,d;
    a=b=c=d=0;
    int q;cin >> q;
    int last=0;
    while(q--){
        int x,y;cin >> x >> y;
        if(x<1||x>n||y<1||y>m){
            if(last>0){
                a++;
            }else if(last<0){
                b++;
            }
            if(last%2==0){
                c++;
            }else{
                d++;
            }
            continue;
        }
        last=v[x][y];
        if(v[x][y]>0){
            a++;
        }else if(v[x][y]<0){
            b++;
        }
        if(v[x][y]%2==0){
            c++;
        }else{
            d++;
        }
    }
    cout << a << " " << b << " " << c << " " << d << "\n";
    return 0;
}