Submission #1273372

#TimeUsernameProblemLanguageResultExecution timeMemory
1273372BlockOGMechanical Doll (IOI18_doll)C++20
6 / 100
115 ms16696 KiB
#include <bits/stdc++.h>

// mrrrow meeow :3
// go play vivid/stasis now! https://vividstasis.gay

#define fo(i, a, b) for (auto i = (a); i < (b); i++)
#define of(i, a, b) for (auto i = (b); i-- > (a);)
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound
#define be(a) a.begin(), a.end()
using namespace std;

int ____init = [] {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    return 0;
}();

void answer(vector<int> c, vector<int> x, vector<int> y);

int s = -1;
vector<int> x, y;

int get_node(vector<int> order) {
    if (order.size() == 1) return order[0];

    int res = s;
    if (order.size() & 1) order.pb(s);
    else {
        fo(i, 0, order.size() / 2) {
            if (order[i] != order[order.size() / 2 + i]) goto nope;
        }

        order.resize(order.size() / 2);
        return get_node(order);

        nope:;
    }
    s--;

    int to_overwrite = x.size();
    x.pb(0), y.pb(0);

    vector<int> left, right;
    fo(i, 0, order.size()) {
        if (i & 1) right.pb(order[i]);
        else left.pb(order[i]);
    }

    x[to_overwrite] = get_node(left);
    y[to_overwrite] = get_node(right);

    return res;
}

void create_circuit(int m, vector<int> a) {
    int n = a.size();

    vector<int> c(m + 1);
    map<int, vector<int>> t;
    c[0] = a[0];
    fo(i, 0, a.size()) {
        t[a[i]].pb(i + 1 < a.size() ? a[i + 1] : 0);
    }

    fo(i, 0, m) if (t.count(i + 1)) c[i + 1] = get_node(t[i + 1]);

    answer(c, x, y);
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...