Submission #1153701

#TimeUsernameProblemLanguageResultExecution timeMemory
1153701wiiScales (IOI15_scales)C++20
0 / 100
1 ms320 KiB
#include "scales.h"
#include <bits/stdc++.h>
using namespace std;

int seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(seed);

int ans[6];
void sh(int id) {
    for (int i = 6; i > id; ++i)
        ans[i] = ans[i - 1];
}

void init(int T) {
    for (int i = 0; i < 6; ++i)
        ans[i] = i + 1;
    shuffle(ans, ans + 6, rng);

    int heavy = getHeaviest(ans[0], ans[1], ans[2]);
    heavy = getHeaviest(ans[3], ans[4], heavy);

    for (int i = 0; i < 5; ++i) if (ans[i] == heavy)
        swap(ans[i], ans[4]);

    sort(ans, ans + 4, [&](int x, int y) {
        return getLightest(x, y, heavy) == x;
    });

    int last = ans[5];
    for (int i = 0; i < 5; i += 2) {
        int k = getNextLightest(ans[i], last, ans[i + 2], ans[i + 1]);

        if (k == ans[i]) {
            sh(i); ans[i] = last; break;
        } else if (k == last) {
            sh(i + 1); ans[i + 1] = last;
        } else if (k == ans[i + 2]) {
            continue;
        }
    }
}

void orderCoins() {
    answer(ans);
}
#Verdict Execution timeMemoryGrader output
Fetching results...