Submission

Status:

PPPPPP-PPP

Subtask/Task Score:

90/100

Score: 90

User: Folk_DIWA

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

Language: cpp

Time: 0.005 second

Submitted On: 2026-10-13 01:47:17

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

using ll = long long;

int main(){
    cin.tie(0)->sync_with_stdio(0);

    int r,c; cin >> r >> c;
    vector <vector<int>> v(r, vector<int>(c));

    vector <pair <int,int>> p;
    for(int i=0; i<r; i++){
        for(int j=0; j<c; j++){
            cin >> v[i][j];
        }
    }

    // for(int i=0; i<r; i++){
    //     for(int j=0; j<c; j++){
    //         cout <<  v[i][j] << ' ';
    //     }
    // }

    int k; cin >> k;
    pair <int,int> mem;

    for(int i=0; i<k; i++){

        int x,y; cin >> x >> y;

        if(x <= 0 or x > r or y <= 0 or y > c){
            p.push_back(mem);
        }
        else{
            p.push_back({x-1, y-1});
            mem.first = x-1;
            mem.second = y-1;
        }

    }

    // for(auto &x : p) cout << x.first << ' ' << x.second << '\n';

    int pos=0,neg=0,even=0,odd=0;

    for(int i=0; i<p.size(); i++){

        if(v[p[i].first][p[i].second]%2 == 0) even++;
        else odd++;

        if(v[p[i].first][p[i].second] > 0) pos++;
        else if(v[p[i].first][p[i].second] < 0) neg++;

    }

    cout << pos << ' ' << neg << ' ' << even << ' ' << odd;
 
    return 0;
}