Submission #475263

# Submission time Handle Problem Language Result Execution time Memory
475263 2021-09-21T17:07:17 Z Beboo44 Knjige (COCI20_knjige) C++14
50 / 50
38 ms 1484 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0)

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

    ll n;
    cin>>n;
    vector<ll>v(n);
    vector<ll>temp(n);
    for(int i=0; i<n; ++i){
        cin>>v[i];
        temp[i]=v[i];
    }
    vector<string>ans;
    vector<ll>righshelf;
    sort(temp.rbegin(),temp.rend());
    ll visited=-1;
    while(v.size()>0){
      if(v[0]!=temp[0] ||(v[0]==temp[0] && visited==1)){
        ans.push_back("UZMI L L");
        ans.push_back("STAVI L D");
        righshelf.push_back(v[0]);
        v.erase(v.begin());
      }
      else{
        ans.push_back("UZMI D L");
        visited=1;
        v.erase(v.begin());
      }
    }
    visited=-1;
    ans.push_back("STAVI D L");
    temp.erase(temp.begin());
    while(temp.size()>0){
        while(righshelf.size()>0){
            if(righshelf[righshelf.size()-1]!=temp[0] || (righshelf[righshelf.size()-1]==temp[0] && visited==1)){
                ans.push_back("UZMI L D");
                ans.push_back("STAVI L L");
                v.push_back(righshelf[righshelf.size()-1]);
                righshelf.erase(righshelf.begin()+righshelf.size()-1);
            }
            else{
                ans.push_back("UZMI D D");
                visited=1;
                righshelf.erase(righshelf.begin()+righshelf.size()-1);
            }
        }
        while(v.size()>0){
            ans.push_back("UZMI L L");
            ans.push_back("STAVI L D");
            righshelf.push_back(v[v.size()-1]);
            v.erase(v.begin()+v.size()-1);
        }
        ans.push_back("STAVI D L");
        temp.erase(temp.begin());
        visited=-1;
    }
    cout<<ans.size()<<endl;
    for(int i=0; i<ans.size(); ++i){
        cout<<ans[i]<<endl;
    }







    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:64:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |     for(int i=0; i<ans.size(); ++i){
      |                  ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 32 ms 1484 KB Output is correct
2 Correct 31 ms 1484 KB Output is correct
3 Correct 32 ms 1356 KB Output is correct
4 Correct 32 ms 1484 KB Output is correct
5 Correct 32 ms 1484 KB Output is correct
6 Correct 34 ms 1356 KB Output is correct
7 Correct 32 ms 1484 KB Output is correct
8 Correct 31 ms 1484 KB Output is correct
9 Correct 38 ms 1356 KB Output is correct
10 Correct 32 ms 1484 KB Output is correct