Submission #1199439

#TimeUsernameProblemLanguageResultExecution timeMemory
1199439raphaelpScales (IOI15_scales)C++20
0 / 100
0 ms320 KiB

#include <bits/stdc++.h>
#include "scales.h"
using namespace std;

void init(int T)
{
}

void orderCoins()
{
    vector<int> W(6);
    int L, H, ML, MH1, MH2;
    L = getLightest(1, 2, 3);
    ML = (L == 1) ? 2 : 1;
    MH1 = (L == 3) ? 2 : 3;
    H = getHeaviest(MH1, 4, 5);
    if (MH1 == H)
        MH1 = 4;
    MH2 = (H == 5) ? 4 : 5;
    int x = getMedian(L, ML, MH1);
    if (x == L)
        swap(MH1, L), swap(ML, MH1);
    else if (x == MH1)
        swap(MH1, ML);
    x = getMedian(MH1, MH2, H);
    if (x == H)
        swap(H, MH1), swap(MH1, MH2);
    else if (x == MH1)
        swap(MH1, MH2);
    x = getMedian(MH1, MH2, 6);
    if (x == 6)
        W = {L, ML, MH1, 6, MH2, H};
    else if (x == MH1)
    {
        x = getMedian(L, ML, 6);
        if (x == 6)
            W = {L, 6, ML, MH1, MH2, H};
        else if (x == L)
            W = {6, L, ML, MH1, MH2, H};
        else
            W = {L, ML, 6, MH1, MH2, H};
    }
    else
    {
        x = getMedian(MH2, H, 6);
        if (x == 6)
            W = {L, ML, MH1, MH2, 6, H};
        else
            W = {L, ML, MH1, MH2, H, 6};
    }
    int ans[6];
    for (int i = 0; i < 6; i++)
        ans[i] = W[i];
    answer(ans);
}
#Verdict Execution timeMemoryGrader output
Fetching results...