# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
483286 | rainboy | Knjige (COCI20_knjige) | C11 | 3 ms | 460 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |