Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: ZanTy

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

Language: cpp

Time: 0.007 second

Submitted On: 2026-10-04 14:35:03

#include <bits/stdc++.h>

int positionx[1005];
int positiony[1005];
int area[305][305];
int a,b,c,d;

int main(){
    int n,m,q,x,y;
    scanf("%d %d",&n,&m);
    for (int i = 1;i <= n;i++){
        for (int j = 1;j <= m;j++){
            scanf("%d",&area[i][j]);
        }
    }
    scanf("%d",&q);
    for (int i = 1;i <= q;i++){
        scanf("%d %d",&x,&y);
        if ((1 <= x && x <= n) && (1 <= y && y <= m)){
            positionx[i] = x;
            positiony[i] = y;
        }
        else {
            positionx[i] = positionx[i-1];
            positiony[i] = positiony[i-1];

        }
    }
    for (int i = 1;i <= q;i++){
        if (!positionx[i] || !positiony[i]){
            continue;
        }
        x = positionx[i];
        y = positiony[i];
        if (area[x][y] > 0){a++;}
        if (area[x][y] < 0){b++;}
        if (abs(area[x][y]) % 2){d++;}
        else {c++;}
    }
    printf("%d %d %d %d",a,b,c,d);
}