Submission #731306

#TimeUsernameProblemLanguageResultExecution timeMemory
731306nihaddhuseynliKnjige (COCI20_knjige)C++14
50 / 50
3 ms664 KiB
#include <bits/stdc++.h> using std::vector; using std::array; using std::pair; using std::tuple; #define TAKE 0 #define PUT 1 #define LEFT 0 #define RIGHT 1 int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); int N; std::cin >> N; vector<int> D(N); for (auto& x : D) { std::cin >> x; } vector<tuple<int, int, int>> ans; while (!D.empty()) { auto itr = std::min_element(D.begin(), D.end()); const int idx = itr - D.begin(); for (int i = 0; i < idx; ++i) { ans.emplace_back(TAKE, LEFT, LEFT); ans.emplace_back(PUT, LEFT, RIGHT); } ans.emplace_back(TAKE, RIGHT, LEFT); for (int i = 0; i < idx; ++i) { ans.emplace_back(TAKE, LEFT, RIGHT); ans.emplace_back(PUT, LEFT, LEFT); } ans.emplace_back(PUT, RIGHT, RIGHT); D.erase(itr); } for (int i = 0; i < N; ++i) { ans.emplace_back(TAKE, LEFT, RIGHT); ans.emplace_back(PUT, LEFT, LEFT); } std::cout << ans.size() << '\n'; for (const auto& [i, h, s] : ans) { std::cout << (i ? "STAVI" : "UZMI") << ' ' << "LD"[h] << ' ' << "LD"[s] << '\n'; } return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:43:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   43 |     for (const auto& [i, h, s] : ans) {
      |                      ^
#Verdict Execution timeMemoryGrader output
Fetching results...