Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: JRomsponCH

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

Language: cpp

Time: 0.010 second

Submitted On: 2025-09-30 14:33:21

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

int main() {
    int r;
    int c;
    cin>>r>>c;
    int arr[r][c];
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            cin>>arr[i][j];
        }
    }
    int n;
    cin>>n;
    int x;
    int y;
    int even = 0;
    int odd = 0;
    int plus = 0;
    int neg = 0;
    bool evenc,oddc,plusc,negc;
    evenc = oddc = plusc = negc = false;
    for (int i = 0; i < n; i++) {
        cin>>x>>y;
        x--,y--;
        if ((x >= 0 and y >= 0) and (x < r and y < c)) {
            evenc = oddc = plusc = negc = false;
            if (arr[x][y] % 2 == 0) {
                even += 1;
                evenc = true;
            }
            if (abs(arr[x][y]) % 2 == 1) {
                odd += 1;
                oddc = true;
            }
            if (arr[x][y] > 0) {
                plus += 1;
                plusc = true;
            }
            if (arr[x][y] < 0) {
                neg += 1;
                negc = true;
            }
        }else{
            if (evenc == true) {
                even += 1;
            }
            if (oddc == true) {
                odd += 1;
            }
            if (plusc == true) {
                plus += 1;
            }
            if (negc == true) {
                neg += 1;
            }
        }
    }
    cout<<plus<<" "<<neg<<" "<<even<<" "<<odd;
}