답안 #388445

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
388445 2021-04-11T14:43:14 Z phathnv Knjige (COCI20_knjige) C++11
50 / 50
6 ms 1608 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int N = 107;

int n, a[N];
vector<string> ans;

void Move(int x){
    for(int i = 1; i < x; i++){
        ans.push_back("UZMI L L");
        ans.push_back("STAVI L D");
    }
    ans.push_back("UZMI D L");
    for(int i = 1; i < x; i++){
        ans.push_back("UZMI L D");
        ans.push_back("STAVI L L");
    }
    ans.push_back("STAVI D L");
    for(int i = x; i > 1; i--)
        swap(a[i], a[i - 1]);
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    for(int i = 1; i <= n; i++){
        int p = max_element(a + i, a + 1 + n) - a;
        Move(p);
    }

    cout << ans.size() << '\n';
    for(string s : ans)
        cout << s << '\n';

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1608 KB Output is correct
2 Correct 5 ms 1608 KB Output is correct
3 Correct 5 ms 1608 KB Output is correct
4 Correct 5 ms 1608 KB Output is correct
5 Correct 5 ms 1608 KB Output is correct
6 Correct 6 ms 1608 KB Output is correct
7 Correct 4 ms 1484 KB Output is correct
8 Correct 5 ms 1608 KB Output is correct
9 Correct 5 ms 1608 KB Output is correct
10 Correct 5 ms 1608 KB Output is correct