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 m, n, a[101][101], dy[4]={0,1,0,-1}, dx[4]={1,0,-1,0};
void input(void)
{
scanf("%d %d",&m,&n);
}
void process(void)
{
int z=0, y=1, x=1, ty, tx;
printf("%d\n",2*m*n);
while(a[y][x]==0)
{
a[y][x]=1;
if((y+x)%2)
{
if(z==0 || z==3)
printf("%d %d 0\n%d %d 1\n",y,x,y,x);
else
printf("%d %d 1\n%d %d 0\n",y,x,y,x);
}
else
{
if(z==0 || z==1)
printf("%d %d 0\n%d %d 1\n",y,x,y,x);
else
printf("%d %d 1\n%d %d 0\n",y,x,y,x);
}
ty=y+dy[z];
tx=x+dx[z];
if(ty>=1 && ty<=m && tx>=1 && tx<=n && a[ty][tx]==0)
{
y=ty;
x=tx;
}
else
{
z++;
z%=4;
ty=y+dy[z];
tx=x+dx[z];
y=ty;
x=tx;
}
}
}
int main(void)
{
input();
process();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |