답안 #880995

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
880995 2023-11-30T10:20:48 Z HossamHero7 Knjige (COCI20_knjige) C++14
0 / 50
0 ms 348 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(st2.size() && 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 --;
            continue;
        }
        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;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Cannot put a book with empty hand
2 Incorrect 0 ms 348 KB Cannot put a book with empty hand
3 Incorrect 0 ms 348 KB Cannot hold multiple books at one hand
4 Incorrect 0 ms 348 KB Cannot put a book with empty hand
5 Incorrect 0 ms 344 KB Cannot put a book with empty hand
6 Incorrect 0 ms 348 KB Cannot put a book with empty hand
7 Incorrect 0 ms 348 KB Cannot put a book with empty hand
8 Incorrect 0 ms 344 KB Cannot put a book with empty hand
9 Incorrect 0 ms 348 KB Cannot put a book with empty hand
10 Incorrect 0 ms 348 KB Wrong configuration