Submission #483286

#TimeUsernameProblemLanguageResultExecution timeMemory
483286rainboyKnjige (COCI20_knjige)C11
50 / 50
3 ms460 KiB
#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 (stderr)

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]);
      |   ^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...