Submission

Status:

PPPPPP-PPP

Subtask/Task Score:

90/100

Score: 90

User: Kidmaiok

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

Language: cpp

Time: 0.005 second

Submitted On: 2026-10-11 20:51:31

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define space << ' '
#define nl << endl
int arr[300][300];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b;
    cin >> a >> b;
    for(int i =0; i < a; i++){
        for(int j =0; j < b; j++){
            int x;
            cin >> x;
            arr[i][j] = x;
        }
    }
    int num,pos=0,neg=0,even=0,odd=0;
    int temp1=0,temp2=0;
    cin >> num;
    for(int i =0; i < num;i++){
        int x,y;
        
        cin >> x >> y;
        if(((x < 1 || x > a) || (y < 1|| y > b)) && i != 0){
            if(arr[temp1-1][temp2-1] % 2 == 0) even++;
            if(arr[temp1-1][temp2-1] % 2 != 0) odd++;
            if(arr[temp1-1][temp2-1] > 0) pos++;
            if(arr[temp1-1][temp2-1] < 0) neg++;
        
        }else{
            temp1 = x;
            temp2 = y;
            if(arr[x-1][y-1] % 2 == 0) even++;
            if(arr[x-1][y-1] % 2 != 0) odd++;
            if(arr[x-1][y-1] > 0) pos++;
            if(arr[x-1][y-1] < 0) neg++;
        }
    }
    cout << pos  space << neg  space << even  space << odd;
}