Submission #5202

#TimeUsernameProblemLanguageResultExecution timeMemory
5202ainta보도블록 (KOI11_block)C++98
22 / 22
4 ms1088 KiB
#include<stdio.h> int n, m, i, j; void Do(){ for (i = 1; i <= n; i++){ printf("%d 1 0\n%d 1 1\n", i, i); } for (i = n; i >= 4; i--){ if ((i & 1) == (n & 1)){ for (j = 2; j <= m; j++){ printf("%d %d %d\n%d %d %d\n", i, j, j & 1, i, j, !(j & 1)); } } else{ for (j = m; j >= 2; j--){ printf("%d %d %d\n%d %d %d\n", i, j, 1, i, j, 0); } } } printf("3 2 0\n2 2 1\n3 2 1\n"); for (j = 3; j <= m; j++){ printf("3 %d %d\n3 %d %d\n", j, j & 1, j, !(j & 1)); } for (j = m; j >= 5; j -= 2){ printf("2 %d 1\n2 %d 0\n1 %d 1\n1 %d 0\n1 %d 1\n1 %d 0\n2 %d 0\n2 %d 1\n", j, j, j, j, j - 1, j - 1, j - 1, j - 1); } printf("2 3 1\n2 3 0\n1 3 1\n1 3 0\n1 2 1\n2 2 0\n1 2 0\n"); } int main() { scanf("%d%d", &n, &m); printf("%d\n", n*m * 2); if (n & 1){ if (m & 1){ Do(); return 0; } printf("1 1 1\n1 1 0\n"); for (i = 2; i <= m; i++){ printf("1 %d 0\n1 %d 1\n", i, i); } for (i = m; i >= 1; i--){ if ((i & 1) == (m & 1)){ for (j = 2; j <= n; j++){ printf("%d %d %d\n%d %d %d\n", j, i, j & 1, j, i, !(j & 1)); } } else{ for (j = n; j >= 2; j--){ printf("%d %d %d\n%d %d %d\n", j, i, 1, j, i, 0); } } } return 0; } for (i = 1; i <= n; i++){ printf("%d 1 0\n%d 1 1\n", i, i); } for (i = n; i >= 1; i--){ if ((i & 1) == (n & 1)){ for (j = 2; j <= m; j++){ printf("%d %d %d\n%d %d %d\n", i, j, !(j & 1), i, j, j & 1); } } else{ for (j = m; j >= 2; j--){ printf("%d %d %d\n%d %d %d\n", i, j, 1, i, j, 0); } } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...