This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<stdio.h>
int k, n, check[1005][1005], p[100005][5];
int input()
{
int i;
scanf("%d",&k);
scanf("%d",&n);
for(i=1 ; i<=n ; i++)
{
scanf("%d %d",&p[i][1],&p[i][2]);
}
return 0;
}
int process()
{
int i, j, num=0, num1=0, num2=0;
for(i=0 ; i<=k ; i++)
{
check[i][i]=1;
if((i-1)>=0)
{
check[i-1][i]=1, check[i][i-1]=1;
}
if((i+1)<=k)
{
check[i][i+1]=1, check[i+1][i]=1;
}
for(j=1 ; j<=k-i ; j++)
{
num=i+j, num1=k-j-1;
if(num<=num1) check[num][i-1]=1;
else break;
}
if(num!=0) check[num][i-1]=1;
num=0, num1=0;
num=k-(i+1);
num1=num/2;
for(j=1 ; j<=num1 ; j++)
{
num2=i+1+j;
check[i][num2]=1;
}
num=0;
num1=0;
num2=0;
}
return 0;
}
int output()
{
int i, y=0, x=0;
for(i=1 ; i<=n ; i++)
{
y=p[i][1], x=p[i][2];
printf("%d\n",check[y][x]);
}
return 0;
}
int main()
{
input();
process();
output();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |