Submission #542013

# Submission time Handle Problem Language Result Execution time Memory
542013 2022-03-25T06:56:03 Z AlperenT Knjige (COCI20_knjige) C++17
50 / 50
2 ms 984 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 100 + 5;

int t, n, arr[N], a = -1, b = -1;

stack<int> lft, rght;

vector<string> ans;

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

    cin >> n;

    for(int i = 1; i <= n; i++) cin >> arr[i];

    for(int i = n; i >= 1; i--) lft.push(arr[i]);

    while(!lft.empty()){
        ans.push_back("UZMI L L");

        a = lft.top(); lft.pop();

        while(!rght.empty() && rght.top() > a){
            ans.push_back("UZMI D D");

            b = rght.top(); rght.pop();

            ans.push_back("STAVI D L");

            lft.push(b); b = -1;
        }

        ans.push_back("STAVI L D");

        rght.push(a); a = -1;
    }

    while(!rght.empty()){
        ans.push_back("UZMI L D");

        a = rght.top(); rght.pop();

        ans.push_back("STAVI L L");

        lft.push(a);
    }

    cout << ans.size() << "\n";

    for(auto str : ans) cout << str << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 856 KB Output is correct
2 Correct 2 ms 856 KB Output is correct
3 Correct 1 ms 856 KB Output is correct
4 Correct 2 ms 856 KB Output is correct
5 Correct 1 ms 984 KB Output is correct
6 Correct 2 ms 856 KB Output is correct
7 Correct 1 ms 728 KB Output is correct
8 Correct 1 ms 856 KB Output is correct
9 Correct 2 ms 984 KB Output is correct
10 Correct 1 ms 856 KB Output is correct