#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1088 KB |
Output is correct |
2 |
Correct |
0 ms |
1088 KB |
Output is correct |
3 |
Correct |
0 ms |
1088 KB |
Output is correct |
4 |
Correct |
0 ms |
1088 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1088 KB |
Output is correct |
2 |
Correct |
0 ms |
1088 KB |
Output is correct |
3 |
Correct |
0 ms |
1088 KB |
Output is correct |
4 |
Correct |
0 ms |
1088 KB |
Output is correct |
5 |
Correct |
0 ms |
1088 KB |
Output is correct |
6 |
Correct |
0 ms |
1088 KB |
Output is correct |
7 |
Correct |
0 ms |
1088 KB |
Output is correct |
8 |
Correct |
0 ms |
1088 KB |
Output is correct |
9 |
Correct |
0 ms |
1088 KB |
Output is correct |
10 |
Correct |
0 ms |
1088 KB |
Output is correct |
11 |
Correct |
0 ms |
1088 KB |
Output is correct |
12 |
Correct |
0 ms |
1088 KB |
Output is correct |
13 |
Correct |
0 ms |
1088 KB |
Output is correct |
14 |
Correct |
4 ms |
1088 KB |
Output is correct |
15 |
Correct |
0 ms |
1088 KB |
Output is correct |
16 |
Correct |
4 ms |
1088 KB |
Output is correct |