Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: SRW

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

Language: cpp

Time: 0.010 second

Submitted On: 2026-09-27 13:18:44

#include <bits/stdc++.h>
using namespace std;
int main(){
    int r,c;
    int k;
    cin >> r >> c;
    int arr[r][c];
    int check[4] = {0};
    for (int i=0;i<r;i++){
        for (int j=0;j<c;j++){
            cin >> arr[i][j];
        }
    }
    cin >> k;
    for (int i=0;i<k;i++){
        int row,column;
        cin >> row >> column;
        if (row <= 0 or column <= 0 or row > r or column  > c){
            continue;
        }
        else{
            if (arr[row-1][column-1] > 0){
                check[0]+=1;
            }
            else if (arr[row-1][column-1] < 0){
                check[1]+=1;
            }
            if (arr[row-1][column-1]%2 == 0){
                check[2]+=1;
            }
            else if (arr[row-1][column-1]%2 != 0){
                check[3]+=1;
            }
        }
    }
    for (int i=0;i<4;i++){
        cout << check[i] << " ";
    }     
}