Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: cyblox_boi

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

Language: cpp

Time: 0.005 second

Submitted On: 2025-10-17 09:19:45

#include <iostream>
#include <vector>
using namespace std;

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

    int r, c;
    cin >> r >> c;

    vector<int> countNumberTypes(4, 0);
    vector<vector<int>> numbers(r, vector<int>(c));

    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            cin >> numbers[i][j];
        }
    }

    int k;
    cin >> k;

    for (int i = 0; i < k; i++)
    {
        int a, b;
        cin >> a >> b;

        a--;
        b--;

        if (a < 0 || a >= r || b < 0 || b >= c)
        {
            continue;
        }

        int result = numbers[a][b];

        if (result > 0)
        {
            countNumberTypes[0]++;
        }
        else if (result < 0)
        {
            countNumberTypes[1]++;
        }

        if (result % 2 == 0)
        {
            countNumberTypes[2]++;
        }
        else
        {
            countNumberTypes[3]++;
        }
    }

    for (const int &i : countNumberTypes)
    {
        cout << i << ' ';
    }

    cout << '\n';

    return 0;
}