Submission #5202

# Submission time Handle Problem Language Result Execution time Memory
5202 2014-02-16T06:49:55 Z ainta 보도블록 (KOI11_block) C++
22 / 22
4 ms 1088 KB
#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 time Memory 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
# Verdict Execution time Memory 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 4 ms 1088 KB Output is correct
16 Correct 4 ms 1088 KB Output is correct