Submission #451987

#TimeUsernameProblemLanguageResultExecution timeMemory
451987PiejanVDCKnjige (COCI20_knjige)C++17
0 / 50
1 ms424 KiB
#include <bits/stdc++.h> using namespace std; signed main() { int n; cin>>n; vector<int>sorted(n); stack<int>l,r; for(int i = 0 ; i < n ; i++) { cin>>sorted[i]; l.push(sorted[i]); } // rechts ==> nemen // links ==> vasthouden sort(sorted.rbegin(),sorted.rend()); bool f = true; for(int i = 0 ; i < n ; i++) { int t = sorted[i]; if(f) { for(int j = 0 ; j < n - i ; j++) { if(l.top() != t) r.push(l.top()), cout << "UZMI D L\nSTAVI D D\n"; else cout << "UZMI L L\n"; l.pop(); } cout << "STAVI L L\n"; l.push(t); f=false; } else { while(true) { if(r.top() == t) break; cout << "UZMI D D\nSTAVI D L\n"; l.push(r.top()); r.pop(); } cout << "UZMI L D\n"; r.pop(); while(l.size() > i) { r.push(l.top()); l.pop(); cout << "UZMI D L\nSTAVI D D\n"; } l.push(t); cout << "STAVI L L\n"; } } }

Compilation message (stderr)

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