Submission
Status:
PPPPPP-PPP
Subtask/Task Score:
90/100
Score: 90
User: wasupum
Problemset: สำรวจอาเรย์ 2
Language: c
Time: 0.005 second
Submitted On: 2025-11-29 21:07:17
#include <stdio.h>
#include <stdbool.h>
int plus,min,odd,even;
int b;
bool ck1(int a){
if(a > 0)return true;
return false;
}
bool ck2(int a){
if(a < 0)return true;
return false;
}
bool ck3(int a){
if(a % 2 == 0)return true;
return false;
}
bool ck4(int a){
if(a % 2 == 1 || a % 2 == -1)return true;
return false;
}
int main(void){
int n,m;scanf("%d %d",&n,&m);
int map[n][m];
for(int i = 0 ;i < n;i++){
for(int j = 0 ; j< m;j++){
int c;scanf("%d",&c);
map[i][j] = c;
}
}
int q ; scanf("%d",&q);
for(int i = 0 ; i < q ; i++){
int x,y,a;
scanf("%d %d",&x,&y);
if((x > 0 && x <= n) && (y > 0 && y <= m)){
a = map[x-1][y-1];
if(ck1(a))plus++;
if(ck2(a))min++;
if(ck3(a))odd++;
if(ck4(a))even++;
b = a;
}else{
if(q != 0){
a = b;
if(ck1(a))plus++;
if(ck2(a))min++;
if(ck3(a))odd++;
if(ck4(a))even++;
}
}
}
printf("%d %d %d %d",plus,min,odd,even);
return 0;
}