답안 #483286

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
483286 2021-10-28T13:21:08 Z rainboy Knjige (COCI20_knjige) C
50 / 50
3 ms 460 KB
#include <stdio.h>

#define N	100
#define M	100000

int main() {
	static int aa[N];
	static char tt[M], xx[M], yy[M];
	int n, m, h, i, j, j_, tmp;

	scanf("%d", &n);
	for (i = n - 1; i >= 0; i--)
		scanf("%d", &aa[i]);
	m = 0;
	for (i = 0; i < n; i++) {
		j_ = i;
		for (j = i + 1; j < n; j++)
			if (aa[j_] < aa[j])
				j_ = j;
		if (j_ == i)
			continue;
		for (j = n - 1; j >= i; j--)
			if (j != j_)
				tt[m] = 'U', xx[m] = 'L', yy[m] = 'L', m++, tt[m] = 'S', xx[m] = 'L', yy[m] = 'D', m++;
			else
				tt[m] = 'U', xx[m] = 'D', yy[m] = 'L', m++;
		tt[m] = 'S', xx[m] = 'D', yy[m] = 'L', m++;
		for (j = i; j <= n - 1; j++)
			if (j != j_)
				tt[m] = 'U', xx[m] = 'L', yy[m] = 'D', m++, tt[m] = 'S', xx[m] = 'L', yy[m] = 'L', m++;
		tmp = aa[j_];
		for (j = j_; j > i; j--)
			aa[j] = aa[j - 1];
		aa[i] = tmp;
	}
	printf("%d\n", m);
	for (h = 0; h < m; h++)
		printf("%s %c %c\n", tt[h] == 'U' ? "UZMI" : "STAVI", xx[h], yy[h]);
	return 0;
}

Compilation message

Main.c: In function 'main':
Main.c:11:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
Main.c:13:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 460 KB Output is correct
2 Correct 3 ms 460 KB Output is correct
3 Correct 3 ms 460 KB Output is correct
4 Correct 3 ms 460 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 2 ms 460 KB Output is correct
9 Correct 2 ms 460 KB Output is correct
10 Correct 2 ms 460 KB Output is correct