Submission #731306

# Submission time Handle Problem Language Result Execution time Memory
731306 2023-04-27T09:18:40 Z nihaddhuseynli Knjige (COCI20_knjige) C++14
50 / 50
3 ms 664 KB
#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

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 time Memory Grader output
1 Correct 2 ms 664 KB Output is correct
2 Correct 3 ms 664 KB Output is correct
3 Correct 2 ms 664 KB Output is correct
4 Correct 2 ms 664 KB Output is correct
5 Correct 2 ms 664 KB Output is correct
6 Correct 2 ms 640 KB Output is correct
7 Correct 2 ms 468 KB Output is correct
8 Correct 2 ms 664 KB Output is correct
9 Correct 2 ms 644 KB Output is correct
10 Correct 2 ms 664 KB Output is correct