Submission #602326

# Submission time Handle Problem Language Result Execution time Memory
602326 2022-07-22T22:07:56 Z skittles1412 Mechanical Doll (IOI18_doll) C++17
100 / 100
82 ms 11448 KB
#include "bits/extc++.h"

using namespace std;

template <typename T>
void dbgh(const T& t) {
    cerr << t << endl;
}

template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
    cerr << t << " | ";
    dbgh(u...);
}

#ifdef DEBUG
#define dbg(...)                                              \
    cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]: "; \
    dbgh(__VA_ARGS__);
#else
#define dbg(...)
#define cerr   \
    if (false) \
    cerr
#endif

#define endl "\n"
#define long int64_t
#define sz(x) int((x).size())

void answer(vector<int> C, vector<int> X, vector<int> Y);

vector<int> arr;
vector<pair<int, int>> ans;

const int none = -1e9;

int n, pref, root = none;

void init(int& o, int l, int r, int i) {
    if (r < pref) {
        o = root;
        return;
    } else if (l == r) {
        o = arr.back();
        arr.pop_back();
        return;
    }
    if (o == none) {
        o = -sz(ans) - 1;
        ans.emplace_back(none, none);
    }
    int mid = (l + r) / 2;
    if (i % 2 == 0) {
        init(ans[-o - 1].first, l, mid, i >> 1);
    } else {
        init(ans[-o - 1].second, mid + 1, r, i >> 1);
    }
}

void create_circuit(int m, vector<int> _arr) {
    arr = _arr;
    int first = arr[0];
    arr.erase(arr.begin());
    arr.push_back(0);
    reverse(begin(arr), end(arr));

    n = sz(arr);
    int targ = 1 << (__lg(n - 1) + 1);
    pref = targ - n;
    ans.reserve(targ * 5);
    for (int i = 0; i < targ; i++) {
        init(root, 0, targ - 1, i);
    }
    vector<int> ans1(m + 1, root);
    ans1[0] = first;
    vector<int> ans2, ans3;
    for (auto& [x, y] : ans) {
        ans2.push_back(x);
        ans3.push_back(y);
    }
    answer(ans1, ans2, ans3);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 224 KB Output is correct
2 Correct 31 ms 4560 KB Output is correct
3 Correct 30 ms 3904 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 9 ms 1364 KB Output is correct
6 Correct 43 ms 5884 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 224 KB Output is correct
2 Correct 31 ms 4560 KB Output is correct
3 Correct 30 ms 3904 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 9 ms 1364 KB Output is correct
6 Correct 43 ms 5884 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 51 ms 7560 KB Output is correct
9 Correct 57 ms 8088 KB Output is correct
10 Correct 82 ms 11448 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 224 KB Output is correct
2 Correct 31 ms 4560 KB Output is correct
3 Correct 30 ms 3904 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 9 ms 1364 KB Output is correct
6 Correct 43 ms 5884 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 51 ms 7560 KB Output is correct
9 Correct 57 ms 8088 KB Output is correct
10 Correct 82 ms 11448 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 78 ms 11096 KB Output is correct
15 Correct 51 ms 7332 KB Output is correct
16 Correct 76 ms 10936 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 304 KB Output is correct
20 Correct 78 ms 11220 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 45 ms 6180 KB Output is correct
3 Correct 45 ms 5936 KB Output is correct
4 Correct 72 ms 9128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 45 ms 6180 KB Output is correct
3 Correct 45 ms 5936 KB Output is correct
4 Correct 72 ms 9128 KB Output is correct
5 Correct 76 ms 9408 KB Output is correct
6 Correct 73 ms 9188 KB Output is correct
7 Correct 72 ms 9224 KB Output is correct
8 Correct 71 ms 9132 KB Output is correct
9 Correct 49 ms 5944 KB Output is correct
10 Correct 71 ms 9032 KB Output is correct
11 Correct 70 ms 8972 KB Output is correct
12 Correct 46 ms 5872 KB Output is correct
13 Correct 48 ms 6216 KB Output is correct
14 Correct 49 ms 6308 KB Output is correct
15 Correct 50 ms 6404 KB Output is correct
16 Correct 2 ms 468 KB Output is correct
17 Correct 46 ms 6104 KB Output is correct
18 Correct 48 ms 6176 KB Output is correct
19 Correct 47 ms 5868 KB Output is correct
20 Correct 69 ms 9064 KB Output is correct
21 Correct 69 ms 9076 KB Output is correct
22 Correct 75 ms 9000 KB Output is correct