Submission #475222

# Submission time Handle Problem Language Result Execution time Memory
475222 2021-09-21T14:35:18 Z Beboo44 Knjige (COCI20_knjige) C++14
0 / 50
34 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());

    while(v.size()>0){
      if(v[0]!=temp[0]){
        ans.push_back("UZMI L L");
        ans.push_back("STAVI L R");
        righshelf.push_back(v[0]);
        v.erase(v.begin());
      }
      else{
        ans.push_back("UZMI L R");
        v.erase(v.begin());
      }
    }
    ans.push_back("STAVI R L");
    temp.erase(temp.begin());
    while(temp.size()>0){
        while(righshelf.size()>0){
            if(righshelf[righshelf.size()-1]!=temp[0]){
                ans.push_back("UZMI R L");
                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 R R");
                righshelf.erase(righshelf.begin()+righshelf.size()-1);
            }
        }
        while(v.size()>0){
            ans.push_back("UZMI L L");
            ans.push_back("STAVI L R");
            righshelf.push_back(v[v.size()-1]);
            v.erase(v.begin()+v.size()-1);
        }
        ans.push_back("STAVI R L");
        temp.erase(temp.begin());
    }
    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:60: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]
   60 |     for(int i=0; i<ans.size(); ++i){
      |                  ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 1484 KB Token "R" doesn't correspond to pattern "(L|D)"
2 Incorrect 30 ms 1464 KB Token "R" doesn't correspond to pattern "(L|D)"
3 Incorrect 32 ms 1484 KB Token "R" doesn't correspond to pattern "(L|D)"
4 Incorrect 32 ms 1460 KB Token "R" doesn't correspond to pattern "(L|D)"
5 Incorrect 34 ms 1484 KB Token "R" doesn't correspond to pattern "(L|D)"
6 Incorrect 32 ms 1484 KB Token "R" doesn't correspond to pattern "(L|D)"
7 Incorrect 17 ms 848 KB Token "R" doesn't correspond to pattern "(L|D)"
8 Incorrect 32 ms 1484 KB Token "R" doesn't correspond to pattern "(L|D)"
9 Incorrect 32 ms 1484 KB Token "R" doesn't correspond to pattern "(L|D)"
10 Incorrect 32 ms 1460 KB Token "R" doesn't correspond to pattern "(L|D)"