Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: rice_ot

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

Language: cpp

Time: 0.005 second

Submitted On: 2025-10-17 11:45:05

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m, q; cin>>n>>m;
	int grid[n][m];
	for(int i = 0; i<n; i++){
	    for(int j = 0; j<m; j++){
	        cin>>grid[i][j];
	    }
	}
	cin>>q;
	int p = 0, ne = 0, e = 0, o = 0;
	int tp = 0, tn = 0, te = 0, to =0;
	
	for(int i = 0; i<q; i++){
	    int y, x; cin>>y>>x;
	    y--; x--;
	    if(y >= n || x >= m || x < 0 || y < 0){
	        p+=tp; ne+=tn; e+=te; o+=to;
	        continue;
	    }
	    else{
	        tp = 0; tn = 0; te = 0; to =0;
	    }
	    
	    if(grid[y][x] > 0) {p++; tp = 1;}
	    else if(grid[y][x] < 0) {ne++; tn = 1;}
	    if(grid[y][x]%2 == 0) {e++; te = 1;}
	    else {o++; to = 1;}
	    
	    
	}
	cout<<p<<" "<<ne<<" "<<e<<" "<<o;
}