Submission #445944

#TimeUsernameProblemLanguageResultExecution timeMemory
445944JasiekstrzKnjige (COCI20_knjige)C++17
50 / 50
5 ms1484 KiB
#include<bits/stdc++.h> #define fi first #define se second using namespace std; const int N=1e5; int h[2]={-1,-1}; vector<int> st[2]; vector<string> ans; void take(bool hand,bool shelf) { h[hand]=st[shelf].back(); st[shelf].pop_back(); ans.push_back((string)"UZMI "+(hand ? "D":"L")+" "+(shelf ? "D":"L")); return; } void put(bool hand,bool shelf) { st[shelf].push_back(h[hand]); h[hand]=-1; ans.push_back((string)"STAVI "+(hand ? "D":"L")+" "+(shelf ? "D":"L")); return; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin>>n; st[0].resize(n); for(int i=1;i<=n;i++) cin>>st[0][n-i]; while(!st[0].empty()) { take(0,0); put(0,1); } for(int i=0;i<n;i++) { take(0,1); while(!st[1].empty()) { if(st[1].back()>h[0]) { put(0,0); take(0,1); } else { take(1,1); put(1,0); } } while(st[0].size()>i) { take(1,0); put(1,1); } put(0,0); } cout<<ans.size()<<"\n"; for(auto v:ans) cout<<v<<"\n"; return 0; }

Compilation message (stderr)

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