Submission

Status:

PPPPPPxPPP

Subtask/Task Score:

90/100

Score: 90

User: helloskibidi

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

Language: cpp

Time: 0.009 second

Submitted On: 2026-10-05 13:53:30

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

int arr[305][305];

int main(){
    int n ,m;
    cin >> n >> m;
    vector<int> prop = {0,0,0,0};
    for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) cin >> arr[i][j];
    
    int x1,y1;

    int a;
    cin >> a;
    for(int i=0;i<a;i++){
        int x , y;
        cin >> x >> y;
        if(x > n || y > m || y < 1 || x < 1){
            if(x1 == -1 || y1 == -1) continue;
            if(arr[x1][y1] > 0 ) prop[0]++;
            if(arr[x1][y1] < 0 ) prop[1]++;
            if(arr[x1][y1]%2 == 0 ) prop[2]++;
            else prop[3]++; 
        }
        else{
            if(arr[x][y] > 0 ) {prop[0]++; x1=x; y1=y;}
            if(arr[x][y] < 0 ) {prop[1]++; x1=x; y1=y;}
            if(arr[x][y]%2 == 0 ) {prop[2]++; x1=x; y1=y;}
            else {prop[3]++; x1=x; y1=y;} 
        }
    }

    for(int s : prop) cout << s << ' ';
}