Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: chokun

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

Language: cpp

Time: 0.010 second

Submitted On: 2026-10-13 08:20:37

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

int main(){
    int r, c;
    cin >> r >> c;
    int a[r][c];
    int count_positive_int = 0;
    int count_negative_int = 0;
    int count_even = 0;
    int count_odd = 0;
    
    for (int i = 0; i < r; i++){
        for (int j = 0; j < c; j++){
            cin >> a[i][j];
        }
    }
    
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        int row, col;
        cin >> row >> col;
        
        if (row < 1 || row > r || col < 1 || col > c) {
            continue;
        }
        
        int val = a[row - 1][col - 1];
        
        if (val > 0) {
            count_positive_int++;
        } else if (val < 0) {
            count_negative_int++;
        }

        if (val % 2 == 0) {
            count_even++;
        } else {
            count_odd++;
        }
    }
    
    cout << count_positive_int << " " << count_negative_int << " " << count_even << " " << count_odd << "\n";
}