Submission #528330

#TimeUsernameProblemLanguageResultExecution timeMemory
528330CyanmondScales (IOI15_scales)C++17
0 / 100
1 ms204 KiB
// clang-format off
#include "scales.h"
#include <bits/stdc++.h>

void init(int T) {
    /* ... */
}

void orderCoins() {
    std::array<int, 3> A, B;
    {
        const int x = getHeaviest(1, 2, 3);
        const int y = getLightest(1, 2, 3);
        int z = 0;
        for (int i = 1; i <= 3; ++i) {
            if (i != x and i != y) z = i;
        }
        A = {y, z, x};
    }
    {
        const int x = getHeaviest(4, 5, 6);
        const int y = getLightest(4, 5, 6);
        int z = 0;
        for (int i = 4; i <= 6; ++i) {
            if (i != x and i != y) z = i;
        }
        B = {y, z, x};
    }

    std::vector<int> res(3);
    for (int i = 0; i < 3; ++i) res[i] = A[i];

    const int r2 = getNextLightest(A[0], A[1], A[2], B[1]);
    if (r2 == A[0]) {
        const bool h = getMedian(A[0], A[1], B[1]) == A[0];
        if (h) {
            res.insert(res.begin(), B[1]);
            res.insert(res.begin(), B[0]);
            int r3 = getNextLightest(A[0], A[1], A[2], B[2]);
            if (r3 == A[0]) res.insert(getMedian(A[0], A[1], B[2]) == A[0] ? res.begin() + 2 : res.end(), B[2]);
            else res.insert(std::find(res.begin(), res.end(), r3), B[2]);
        } else {
            res.insert(res.end(), B[1]);
            res.insert(res.end(), B[2]);
            int r1 = getNextLightest(A[0], A[1], A[2], B[0]);
            if (r1 == A[0]) res.insert(getMedian(A[0], A[1], B[0]) == A[0] ? res.begin() : res.end() - 1, B[0]);
            else res.insert(std::find(res.begin(), res.end(), r1), B[0]);
        }
    } else {
        const int r1 = getNextLightest(A[0], A[1], A[2], B[0]);
        res.insert(std::find(res.begin(), res.end(), r1), B[0]);
        res.insert(std::find(res.begin(), res.end(), r2), B[1]);
        const int r3 = getNextLightest(A[0], A[1], A[2], B[2]);
        res.insert(r3 == A[0] ? res.end() : std::find(res.begin(), res.end(), r3), B[2]);
    }
    
    int gb[6];
    for (int i = 0; i < 6; ++i) gb[i] = res[i];
    answer(gb);
}

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:5:15: warning: unused parameter 'T' [-Wunused-parameter]
    5 | void init(int T) {
      |           ~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...