제출 #419104

#제출 시각아이디문제언어결과실행 시간메모리
419104LouayFarah저울 (IOI15_scales)C++14
0 / 100
1 ms296 KiB
#include "bits/stdc++.h"
#include "scales.h"
using namespace std;

int t;
void init(int T)
{
    t = T;
}

int getHeaviest(int a, int b, int c);
int getMedian(int a, int b, int c);
int getLightest(int a, int b, int c);
int getNextLightest(int a, int b, int c, int d);
void answer(int w[]);

void orderCoins()
{
    for(int cas = 0; cas<t; cas++)
    {
        int w[6];
        int a[3], b[3];
        a[0] = getLightest(1, 2, 3);
        a[1] = getMedian(1, 2, 3);
        a[2] = getHeaviest(1, 2, 3);
        b[0] = getLightest(4, 5, 6);
        b[1] = getMedian(4, 5, 6);
        b[2] = getHeaviest(4, 5, 6);

        int reste = 6;
        int i = 0, j = 0;
        int k = 0;
        while(reste>=3&&i<3&&j<3)
        {
            if(i<2)
            {
                int x = getLightest(a[i], a[i+1], b[j]);
                if(x==a[i])
                {
                    w[k++] = a[i];
                    i++;
                }
                else
                {
                    w[k++] = b[j];
                    j++;
                }
            }
            else if(i==2)
            {
                int x = getLightest(a[i], b[j], b[j+1]);
                if(x==a[i])
                {
                    w[k++] = a[i];
                    i++;
                }
                else
                {
                    w[k++] = b[j];
                    j++;
                }
            }
            reste--;
        }

        if(i==3)
        {
            while(j<3)
            {
                w[k++] = b[j++];
            }
        }
        else if(j==3)
        {
            while(i<3)
            {
                w[k++] = a[i++];
            }
        }
        else
        {
            int x = getHeaviest(a[i], b[j], a[0]);
            if(x==b[j])
            {
                w[4] = a[i];
                w[5] = b[j];
            }
            else
            {
                w[4] = b[j];
                w[5] = a[i];
            }
        }

        answer(w);
    }

    return;
}
#Verdict Execution timeMemoryGrader output
Fetching results...