Submission

Status:

xxxxxxxxxx

Subtask/Task Score:

0/100

Score: 0

User: NovemNotes

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

Language: cpp

Time: 0.005 second

Submitted On: 2025-10-15 13:39:38

#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&1){
                d++;
            }else if(v[x][y]!=0){
                c++;
            }
            continue;
        }
        last=v[x][y];
        if(v[x][y]>0){
            a++;
        }else if(v[x][y]<0){
            b++;
        }
        if(v[x][y]&1){
            d++;
        }else if(v[x][y]!=0){
            c++;
        }
    }
    cout << a << " " << b << " " << c << " " << d << "\n";
    return 0;
}
/*
5 7 
0 -1  2  3 -3 -7  7 
11  7 -4 12 17 -6 -3
-7 12 11 -9 -1  0 20 
0 -2  8 10 -5  8  6
-3 8 -1 -2 -3 -4 -5
12 
4 2 
1 1 
-3 2 
3 4 
2 6 
2 0 
8 1 
1 4 
4 5 
3 7 
5 2 
4 8
*/