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;
int main(void) {
int i, j;
scanf("%d %d",&M,&N);
printf("%d\n",2*M*N);
if(M%2) {
if(N%2) {
for(i=2 ; i<=N ; i++) {
if(i%2)
printf("1 %d 0\n1 %d 1\n",i,i);
else
printf("1 %d 0\n2 %d 0\n1 %d 1\n",i,i,i);
}
printf("2 %d 0\n2 %d 1\n3 %d 0\n3 %d 1\n3 %d 1\n2 %d 1\n3 %d 0\n",N,N,N,N,N-1,N-1,N-1);
for(i=N-2 ; i>=2 ; i--) {
if(i%2)
printf("3 %d 1\n3 %d 0\n2 %d 1\n2 %d 0\n",i,i,i,i);
else
printf("2 %d 1\n3 %d 1\n3 %d 0\n",i,i,i);
}
for(i=4 ; i<=M ; i++) {
if(i%2)
for(j=N ; j>=2 ; j--) {
if((i+j)%2)
printf("%d %d 1\n%d %d 0\n",i,j,i,j);
else
printf("%d %d 0\n%d %d 1\n",i,j,i,j);
}
else
for(j=2 ; j<=N ; j++)
printf("%d %d 0\n%d %d 1\n",i,j,i,j);
}
for(i=M ; i>=1 ; i--)
printf("%d 1 1\n%d 1 0\n",i,i);
}
else {
for(i=1 ; i<=N ; i++) {
if(i%2)
for(j=2 ; j<=M ; j++)
printf("%d %d 0\n%d %d 1\n",j,i,j,i);
else
for(j=M ; j>=2 ; j--) {
if((i+j)%2)
printf("%d %d 0\n%d %d 1\n",j,i,j,i);
else
printf("%d %d 1\n%d %d 0\n",j,i,j,i);
}
}
for(i=N ; i>=1 ; i--) {
if((i+1)%2)
printf("1 %d 1\n1 %d 0\n",i,i);
else
printf("1 %d 0\n1 %d 1\n",i,i);
}
}
}
else {
for(i=1 ; i<=M ; i++) {
if(i%2)
for(j=2 ; j<=N ; j++)
printf("%d %d 0\n%d %d 1\n",i,j,i,j);
else
for(j=N ; j>=2 ; j--) {
if((i+j)%2)
printf("%d %d 1\n%d %d 0\n",i,j,i,j);
else
printf("%d %d 0\n%d %d 1\n",i,j,i,j);
}
}
for(i=M ; i>=1 ; i--)
printf("%d 1 1\n%d 1 0\n",i,i);
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |