Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: anonymous

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

Language: cpp

Time: 0.005 second

Submitted On: 2026-10-01 15:40:14

#include <bits/stdc++.h>

int mp[405][405];
int a,b,c,d;
int la,lb,lc,ld;
using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int x,y;
	cin >> x >> y;
	for(int i=1;i<=x;i++)
	{
		for(int j=1;j<=y;j++)
			{
				cin >> mp[i][j];
			}
	}
	
	int type; cin >> type;
	
	while (type--) {
        int x1,y1;
        cin >> x1 >> y1;
        if (x1 < 1 || x1 > x || y1 < 1 || y1 > y) {
            a+=la;
            b+=lb;
            c+=lc;
            d+=ld;
            continue;
        }
		else
		{
			int num = mp[x1][y1];
       		if (num > 0)
			   {
			   	a++; la = 1;
			   }
			else la=0;
      		if (num < 0)
				{
				b++; lb = 1;
				}
			else lb=0;
        	if (num % 2 == 0) 
			{
			c++; lc=1; ld=0;
			}
        	else 
			{
			d++; ld=1; lc=0;
			}
		}
        
    } 
    cout << a << ' ' << b << ' ' << c << ' ' << d;
	
	
}