Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: Kei

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

Language: cpp

Time: 0.005 second

Submitted On: 2026-10-08 14:22:29

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;

void solve(){
    int r,c,k; cin >> r >> c;
    int p=0,n=0,e=0,o=0;
    vector<vector<int>> mat(r, vector<int>(c));
    for(vector<int>& row : mat){
        for(int& cn : row){
            cin >> cn;
        }
    }
    cin >> k;
    vector<pii> coords(k);
    for(int i=0;i<k;i++){
        cin >> coords[i].first >> coords[i].second;
    }
    for(pii& x : coords){
        if(x.first < 1 || x.first > r || x.second < 1 || x.second > c) continue;
        if(mat[x.first-1][x.second-1]%2 == 0) e++;
        else o++;
        if(mat[x.first-1][x.second-1]>0) p++;
        else if(mat[x.first-1][x.second-1]<0) n++;
    }
    cout << p << ' ' << n << ' ' << e << ' ' << o;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}