Submission

Status:

----------

Subtask/Task Score:

0/100

Score: 0

User: APNICHANAN

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

Language: cpp

Time: 0.009 second

Submitted On: 2025-10-05 18:30:36

#include <iostream>
using namespace std;
int main()
{
    int r, c, ip = 0, in = 0, e = 0, o = 0, n;
    cin >> r >> c;
    int a[r][c];
    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            cin >> a[i][j];
        }
    }
    cin >> n;
    int x[n], y[n];
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
        if (x[i] > r || y[i] > c || x[i] <= 0 || y[i] <= 0)
        {
            x[i] = x[i - 1];
            y[i] = y[i - 1];
        }

        if (a[x[i] - 1][y[i] - 1] > 0)
        {
            ip++;
        }
        else if (a[x[i] - 1][y[i] - 1] < 0)
        {
            in++;
        }

        if (a[x[i] - 1][y[i] - 1] % 2 == 0)
        {
            e++;
        }
        else if (a[x[i] - 1][y[i] - 1] % 2 == 1)
        {
            o++;
        }
    }
    cout << ip << " " << in << " " << e << " " << o << endl;
}