Submission #489273

#TimeUsernameProblemLanguageResultExecution timeMemory
489273inksamuraiKnjige (COCI20_knjige)C++17
0 / 50
3 ms880 KiB
#include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define sz(a) (int)a.size() #define all(a) a.begin(),a.end() #define rep(i,n) for(int i=0;i<n;i++) #define crep(i,x,n) for(int i=x;i<n;i++) #define drep(i,n) for(int i=n-1;i>=0;i--) #define vec(...) vector<__VA_ARGS__> #define _3HIYw7x ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0) using namespace std; typedef long long ll; typedef long double ld; using pii=pair<int,int>; using vi=vector<int>; int main(){ _3HIYw7x; int n; cin>>n; vi a(n); rep(i,n){ cin>>a[i]; } vi _a=a; sort(all(_a)); vi l,r; l=a; reverse(all(l)); vec(tuple<int,int,int>) pans; auto take=[&](int t,int t1){ pans.pb({0,t,t1}); }; auto put=[&](int t,int t1){ pans.pb({1,t,t1}); }; rep(i,n){ int x=_a[i]; while(sz(l) and l.back()!=x){ take(0,0); put(0,1); r.pb(l.back()); l.pop_back(); } take(1,0); l.pop_back(); while(sz(l)){ take(0,0); put(0,1); r.pb(l.back()); l.pop_back(); } put(1,0); while(sz(r)){ take(0,1); put(0,0); l.pb(r.back()); r.pop_back(); } } cout<<sz(pans)<<"\n"; for(auto [t,h,b] : pans){ if(t==0){ cout<<"UZMI "; }else{ cout<<"STAVI "; } cout<<(h==0?"L":"D")<<" "<<(b==0?"L":"D")<<"\n"; } // return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...