Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: herespeed

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

Language: cpp

Time: 0.009 second

Submitted On: 2026-10-14 13:21:10

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

struct p{
	int r,c;
};

int main(){
	int r,c;
	cin>>r>>c;
 	int matrix[r][c];
 	for(int i=0;i<r;++i){
 		for(int j=0;j<c;++j){
 			cin>>matrix[i][j];
		 }
	}
	
	int po =0;
	int ne =0;
	int even=0;
	int odd =0;
	int n;
	cin>>n;
	p point;
	for(int i=0;i<n;++i){
		p temp;
		cin>>temp.r>>temp.c;
		if(!(temp.r<=r&&temp.r>0&& temp.c<=c&&temp.c>0)) continue;
		
		temp.r--; temp.c--; // make into index
		if(matrix[temp.r][temp.c]>0){
			po++;
		}
		else if(matrix[temp.r][temp.c]<0){
			ne++;
		}
		if(matrix[temp.r][temp.c]%2==0){
			even++;
		}
		else{
			odd++;
		}
		
	}
	
	cout<<po<<" "<<ne<<" "<<even<<" "<<odd;
	
}