Submission

Status:

PPPPPP-PPP

Subtask/Task Score:

90/100

Score: 90

User: Karatat007

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

Language: cpp

Time: 0.006 second

Submitted On: 2026-10-03 15:36:00

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int r,c;
    int pos = 0,neg = 0,even = 0,odd = 0;
    cin >> r >> c;
    int cor[r][c];
    for(int i = 0;i < r;++i){
        for(int j = 0;j < c;++j){
            cin >> cor[i][j];
        }
    }
    int n;
    cin >> n;
    int remember;
    for(int i = 0;i < n;++i){
        int x,y,z;
        cin >> x >> y;
        if(x <= 0 or y <= 0 or x > r or y > c){
            if(remember % 2 == 0) ++even;
            else ++odd;
            if(remember > 0) ++pos;
            if(remember < 0) ++neg;
        }
        else{
            z = cor[x - 1][y - 1];
            if(z % 2 == 0) ++even;
            else ++odd;
            if(z > 0) ++pos;
            if(z < 0) ++neg;
        remember = z;
        }
    }
    cout << pos << ' ' << neg << ' ' << even << ' ' << odd; 
}