Submission #63276

#TimeUsernameProblemLanguageResultExecution timeMemory
63276KubalionzzaleScales (IOI15_scales)C++14
55.56 / 100
3 ms680 KiB
#include "scales.h"
#include <vector>
#include <iostream>

int ans[] = {1, 2, 3, 4, 5, 6};
std::vector<int> vec;
int left[5], right[5];

void check4()
{
    int val = getNextLightest(left[0], left[1], 4, left[2]);

    if (val == 4)
    {
        int otherVal = getMedian(left[0], left[1], 4);

        if (otherVal == left[0])
        {
            vec.insert(vec.begin() + 0, 4);
        }
        else
        {
            vec.insert(vec.begin() + 3, 4);
        }
    }
    else
    {
        int otherVal = getMedian(left[0], left[1], 4);

        if (otherVal == 4)
        {
            vec.insert(vec.begin() + 1, 4);
        }
        else if (otherVal == vec[0])
        {
            vec.insert(vec.begin() + 0, 4);
        }
        else
        {
            vec.insert(vec.begin() + 2, 4);
        }
    }
}

void check5()
{
    int val = getNextLightest(vec[0], vec[1], 5, vec[2]);

    if (val == 5)
    {
        int otherVal = getMedian(vec[2], vec[3], 5);

        if (otherVal == vec[2])
        {
            vec.insert(vec.begin() + 0, 5);
        }
        else if (otherVal == vec[3])
        {
            vec.insert(vec.begin() + 4, 5);
        }
        else
        {
            vec.insert(vec.begin() + 3, 5);
        }
    }
    else
    {
        int otherVal = getMedian(vec[0], vec[1], 5);

        if (otherVal == 5)
        {
            vec.insert(vec.begin() + 1, 5);
        }
        else if (otherVal == vec[0])
        {
            vec.insert(vec.begin() + 0, 5);
        }
        else
        {
            vec.insert(vec.begin() + 2, 5);
        }
    }
}

void check6()
{
    int val = getMedian(vec[2], vec[3], 6);

    if (val == 6)
    {
        vec.insert(vec.begin() + 3, 6);
    }
    else if (val == vec[2])
    {
        int otherVal = getMedian(vec[0], vec[1], 6);

        if (otherVal == 6)
        {
            vec.insert(vec.begin() + 1, 6);
        }
        else if (otherVal == vec[0])
        {
            vec.insert(vec.begin() + 0, 6);
        }
        else
        {
            vec.insert(vec.begin() + 2, 6);
        }
    }
    else if (val == vec[3])
    {
        int otherVal = getMedian(vec[3], vec[4], 6);

        if (otherVal == 6)
        {
            vec.insert(vec.begin() + 4, 6);
        }
        else if (otherVal == vec[4])
        {
            vec.insert(vec.begin() + 5, 6);
        }
    }
}

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

void orderCoins() {
    vec.clear();
    int used[7] = { 0 };
    left[0] = getLightest(1, 2, 3);
    left[1] = getMedian(1, 2, 3);

    ++used[left[0]];
    ++used[left[1]];
    for (int i = 1; i <= 3; ++i)
    {
        if (!used[i])
            left[2] = i;
    }

    for (int i = 0; i < 3; ++i)
    {
        vec.push_back(left[i]);
    }

    check4();
    check5();
    check6();

    for (int i = 0; i < 6; ++i)
    {
        ans[i] = vec[i];
    }

    answer(ans);
}

Compilation message (stderr)

In file included from grader.c:2:0:
graderlib.c: In function 'void answer(int*)':
graderlib.c:53:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if (_ghksjhdfkae19ga_ > 1) 
     ^~
graderlib.c:56:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  for (i = 0; i < 6; i++) {
  ^~~
scales.cpp: In function 'void init(int)':
scales.cpp:125:15: warning: unused parameter 'T' [-Wunused-parameter]
 void init(int T) {
               ^
#Verdict Execution timeMemoryGrader output
Fetching results...