답안 #439794

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
439794 2021-06-30T19:30:57 Z rainboy Jetpack (COCI16_jetpack) C
80 / 80
18 ms 3268 KB
#include <stdio.h>

#define N	100000
#define H	10

int main() {
	static char cc[H][N + 1], can[H][N];
	int n, h, i, k, l;

	scanf("%d", &n);
	for (h = 0; h < H; h++)
		scanf("%s", cc[h]);
	for (h = 0; h < H; h++)
		can[h][n - 1] = cc[h][n - 1] == '.';
	for (i = n - 2; i >= 0; i--)
		for (h = 0; h < H; h++)
			if (cc[h][i] == '.' && (can[h == 0 ? 0 : h - 1][i + 1] || can[h == 9 ? 9 : h + 1][i + 1]))
				can[h][i] = 1;
	l = 0;
	for (h = 9, i = 0, k = 0; i < n; i++)
		if (i + 1 < n && can[h == 0 ? 0 : h - 1][i + 1])
			h = h == 0 ? 0 : h - 1, k++;
		else {
			h = h == 9 ? 9 : h + 1;
			if (k > 0)
				l++, k = 0;
		}
	printf("%d\n", l);
	for (h = 9, i = 0, k = 0; i < n; i++)
		if (i + 1 < n && can[h == 0 ? 0 : h - 1][i + 1])
			h = h == 0 ? 0 : h - 1, k++;
		else {
			h = h == 9 ? 9 : h + 1;
			if (k > 0)
				printf("%d %d\n", i - k, k), k = 0;
		}
	return 0;
}

Compilation message

jetpack.c: In function 'main':
jetpack.c:10:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
jetpack.c:12:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   scanf("%s", cc[h]);
      |   ^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 3 ms 844 KB Output is correct
8 Correct 7 ms 1696 KB Output is correct
9 Correct 14 ms 2416 KB Output is correct
10 Correct 18 ms 3268 KB Output is correct