Submission #881004

# Submission time Handle Problem Language Result Execution time Memory
881004 2023-11-30T10:31:19 Z HossamHero7 Knjige (COCI20_knjige) C++14
0 / 50
9 ms 9692 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
void solve(){
    int n;
    cin>>n;
    vector<int> st1 , st2;
    for(int i=0;i<n;i++) {
        int x;cin>>x;
        st1.push_back(x);
    }
    vector<string> ans;
    while(st1.size()){
        if(st1.back() == n){
            ans.push_back("UZMI L L");
            st1.pop_back();
        }
        else {
            ans.push_back("UZMI D L");
            ans.push_back("STAVI D D");
            st2.push_back(st1.back());
            st1.pop_back();
        }
    }
    ans.push_back("STAVI L L");
    int tar = n - 1;
    while(tar){
        if(st2.back() == tar){
            ans.push_back("UZMI L D");
            st2.pop_back();
            while(st1.size()){
                ans.push_back("UZMI D L");
                ans.push_back("STAVI D D");
                st2.push_back(st1.back());
                st1.pop_back();
            }
            ans.push_back("STAVI L L");
            tar --;
        }
        else {
            ans.push_back("UZMI D D");
            ans.push_back("STAVI D L");
            st1.push_back(st2.back());
            st2.pop_back();
        }
    }
    cout<<ans.size()<<endl;
    for(auto i : ans) cout<<i<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);      cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 9692 KB Execution killed with signal 11
2 Runtime error 7 ms 7900 KB Execution killed with signal 11
3 Runtime error 8 ms 8924 KB Execution killed with signal 11
4 Runtime error 7 ms 7908 KB Execution killed with signal 11
5 Runtime error 7 ms 7900 KB Execution killed with signal 11
6 Runtime error 7 ms 8156 KB Execution killed with signal 11
7 Runtime error 8 ms 9180 KB Execution killed with signal 11
8 Runtime error 7 ms 9692 KB Execution killed with signal 11
9 Runtime error 7 ms 7900 KB Execution killed with signal 11
10 Runtime error 7 ms 8152 KB Execution killed with signal 11