Submission #704900

#TimeUsernameProblemLanguageResultExecution timeMemory
7049001075508020060209tcKnjige (COCI20_knjige)C++14
50 / 50
3 ms984 KiB
//#pragma GCC optimize("O3") #include<bits/stdc++.h> using namespace std; #define int long long #define X first #define Y second int n; int ar[500005]; int freq[500005]; vector<pair<int,pair<char,char>>>ans; stack<int>stkl;stack<int>stkr; void swplr(){ ans.push_back({1,{'L','L'}}); ans.push_back({0,{'L','R'}}); stkr.push(stkl.top()); stkl.pop(); } void swprl(){ ans.push_back({1,{'L','R'}}); ans.push_back({0,{'L','L'}}); stkl.push(stkr.top()); stkr.pop(); } signed main(){ cin.tie(0); ios_base::sync_with_stdio(0); cin>>n; for(int i=n;i>=1;i--){ cin>>ar[i]; } for(int i=1;i<=n;i++){ stkl.push(ar[i]); freq[ar[i]]++; } for(int i=1;i<=n;i++){ swplr(); } sort(ar+1,ar+n+1); for(int i=n;i>=1;i--){ int rhand=0; while(stkr.size()){ if(stkr.top()==ar[i]&&rhand==0){ ans.push_back({1,{'R','R'}}); rhand=1; stkr.pop(); continue; } swprl(); } while(stkl.size()){ swplr(); } ans.push_back({0,{'R','L'}}); } cout<<ans.size()<<endl; for(int i=0;i<ans.size();i++){ if(ans[i].first==0){ cout<<"STAVI "; }else{ cout<<"UZMI "; } if(ans[i].second.first=='R'){ cout<<"D "; }else{ cout<<"L "; } if(ans[i].second.second=='R'){ cout<<"D\n"; }else{ cout<<"L\n"; } } }

Compilation message (stderr)

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