Submission #377832

#TimeUsernameProblemLanguageResultExecution timeMemory
377832kshitij_sodaniKnjige (COCI20_knjige)C++14
50 / 50
3 ms492 KiB
//#pragma GCC optimize("Ofast,unroll-loops") #include <bits/stdc++.h> using namespace std; typedef long long llo; #define mp make_pair #define pb push_back #define a first #define b second #define endl '\n' int it[101]; int n; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin>>n; vector<int> ss; for(int i=0;i<n;i++){ cin>>it[i]; ss.pb(it[i]); } sort(ss.begin(),ss.end()); int ans=0; for(int i=0;i<n;i++){ ans+=2; ans+=4*(n-i-1); } //reverse(ss.begin(),ss.end()); for(int i=0;i<n/2;i++){ swap(it[i],it[n-i-1]); } cout<<ans<<endl; for(int i=0;i<n;i++){ int x=ss[n-i-1]; int st=0; for(int j=n-1;j>=i;j--){ if(st==0){ if(it[j]==x){ st=j+1; } } } st--; vector<int> tt; for(int j=i;j<n;j++){ if(j!=st){ tt.pb(it[j]); // cout<<it[j]<<","; } } // cout<<endl; it[i]=ss[n-i-1]; for(int k=0;k<tt.size();k++){ it[i+k+1]=tt[k]; } /*for(int j=0;j<n;j++){ cout<<it[j]<<":"; } cout<<endl;*/ for(int j=n-1;j>=i;j--){ if(j==st){ cout<<"UZMI D L"<<endl; } else{ cout<<"UZMI L L"<<endl; cout<<"STAVI L D"<<endl; } } cout<<"STAVI D L"<<endl; for(int j=n-1;j>=i;j--){ if(j==st){ } else{ cout<<"UZMI L D"<<endl; cout<<"STAVI L L"<<endl; } } } return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:54:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |   for(int k=0;k<tt.size();k++){
      |               ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...