Submission #1199414

#TimeUsernameProblemLanguageResultExecution timeMemory
1199414raphaelp저울 (IOI15_scales)C++20
71.43 / 100
0 ms328 KiB

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

void init(int T)
{
}

void orderCoins()
{
    vector<int> W(6);
    int H1, H2, x;
    H1 = getHeaviest(1, 2, 3);
    H2 = getHeaviest(4, 5, 6);
    x = (H1 == 1) ? 2 : 1;
    int temp = getMedian(H1, H2, x);
    if (temp == x)
        swap(H2, H1), swap(x, H1);
    else if (temp == H2)
        swap(H2, H1);
    vector<int> left;
    for (int i = 1; i <= 6; i++)
        if (i != H1 && i != H2 && i != x)
            left.push_back(i);
    int L1, L2, L3;
    L1 = getNextLightest(left[0], left[1], left[2], H1);
    for (int i = 0; i < 3; i++)
        if (L1 == left[i])
            swap(left[i], left.back()), left.pop_back();
    L2 = getNextLightest(left[0], left[1], H2, L1);
    if (L2 == H2)
    {
        int a = getLightest(left[0], left[1], x);
        int b = getHeaviest(left[0], left[1], x);
        W[0] = a, W[2] = b, W[1] = x;
        for (int i = 0; i < 2; i++)
            if (left[i] != a && left[i] != b)
                W[1] = left[i];
        W[3] = H1, W[4] = L1, W[5] = H2;
    }
    else
    {
        if (left[0] == L2)
            swap(left[0], left[1]);
        L3 = getNextLightest(left[0], x, H2, L2);
        if (L3 == H2)
        {
            int a = getLightest(x, left[0], H2);
            W = {a, ((a == x) ? left[0] : x), H1, L1, L2, H2};
        }
        else if (L3 == x)
        {
            W = {L1, L2, x, left[0], H1, H2};
        }
        else
        {
            int a = getMedian(x, L1, L2);
            if (a == x)
                W = {L1, x, L2, L3, H1, H2};
            else if (a == L1)
                W = {x, L1, L2, L3, H1, H2};
            else
                W = {L1, L2, L3, x, H1, H2};
        }
    }
    int ans[6];
    for (int i = 0; i < 6; i++)
        ans[i] = W[i];
    answer(ans);
}
#Verdict Execution timeMemoryGrader output
Fetching results...