Submission #286341

#TimeUsernameProblemLanguageResultExecution timeMemory
286341AaronNaiduScales (IOI15_scales)C++14
55.56 / 100
1 ms256 KiB
#include <bits/stdc++.h>
#include "scales.h"
using namespace std;

int t;
int answerVector[6];


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

/*int getLightest(int a, int b, int c) {
    cout << "Lightest of " << a << " " << b << " " << c << "\n";
    int ans;
    cin >> ans;
    return ans;
}

int getMedian(int a, int b, int c) {
    cout << "Median of " << a << " " << b << " " << c << "\n";
    int ans;
    cin >> ans;
    return ans;
}

void answer(int v[6]) {
    cout << "Answer:\n";
    for (int i = 0; i < 6; i++)
    {
        cout << v[i] << " ";
    }
}*/

void assign(int a, int b, int c, int d, int e, int f) {
    answerVector[0] = a;
    answerVector[1] = b;
    answerVector[2] = c;
    answerVector[3] = d;
    answerVector[4] = e;
    answerVector[5] = f;
}


void orderCoins() {
    int a = getLightest(1, 2, 3);
    int b = getMedian(1, 2, 3);
    int c;
    for (int i = 1; i <= 3; i++)
    {
        if (i != a and i != b)
        {
            c = i;
        }
    }
    int d = getLightest(4, 5, 6);
    int e = getMedian(4, 5, 6);
    int f;
    for (int i = 4; i <= 6; i++)
    {
        if (i != d and i != e)
        {
            f = i; 
        }
    }
    int x;
    x = getMedian(d, a, b);
    if (x == b)
    {
        int y = getMedian(b, c, d);
        if (y == c)
        {
            assign(a, b, c, d, e, f);
            answer(answerVector);
            return;
        }
       else
       {
           y = getMedian(d, c, e);
           if (y == c)
           {
               assign(a, b, d, c, e, f);
               answer(answerVector);
               return;
           }
           y = getMedian(e, c, f);
           if (y == c)
           {
               assign(a, b, d, e, c, f);
           }
           else
           {
               assign(a, b, d, e, f, c);
           }
           answer(answerVector);
           return;
       }
    }
    if (x == d)
    {
        int y = getMedian(e, b, c);
        if (y == c)
        {
            assign(a, d, b, c, e, f);
            answer(answerVector);
            return;
        }
        if (y == b)
        {
            int z = getMedian(b, c, f);
            if (z == b)
            {
                assign(a, d, e, f, b, c);
                answer(answerVector);
                return;
            }
            if (z == c)
            {
                assign(a, d, e, b, c, f);
                answer(answerVector);
                return;
            }
            assign(a, d, e, b, f, c);
            answer(answerVector);
            return;
        }
        int z = getMedian(e, c, f);
        if (z == f)
        {
            assign(a, d, b, e, f, c);
            answer(answerVector);
            return;
        }
        assign(a, d, b, e, c, f);
        answer(answerVector);
        return;
    }
    x = getMedian(e, a, b);
    if (x == e)
    {
        int y = getMedian(b, c, f);
        if (y == b)
        {
            assign(d, a, e, f, b, c);
            answer(answerVector);
            return;
        }
        if (y == c)
        {
            assign(d, a, e, b, c, f);
            answer(answerVector);
            return;
        }
        assign(d, a, e, b, f, c);
        answer(answerVector);
        return;
    }
    if (x == b)
    {
        int y = getMedian(b, e, c);
        if (y == c)
        {
            assign(d, a, b, c, e, f);
            answer(answerVector);
            return;
        }
        y = getMedian(e, c, f);
        if (y == f)
        {
            assign(d, a, b, e, f, c);
            answer(answerVector);
            return;
        }
        assign(d, a, b, e, c, f);
        answer(answerVector);
        return;
    }
    x = getMedian(f, a, b);
    if (x == a)
    {
        assign(d, e, f, a, b, c);
        answer(answerVector);
        return;
    }
    if (x == f)
    {
        assign(d, e, a, f, b, c);
        answer(answerVector);
        return;
    }
    x = getMedian(b, c, f);
    if (x == f)
    {
        assign(d, e, a, b, f, c);
        answer(answerVector);
        return;
    }
    assign(d, e, a, b, c, f);
    answer(answerVector);
    return;
}

Compilation message (stderr)

scales.cpp: In function 'void orderCoins()':
scales.cpp:41:21: warning: 'f' may be used uninitialized in this function [-Wmaybe-uninitialized]
   41 |     answerVector[5] = f;
      |     ~~~~~~~~~~~~~~~~^~~
scales.cpp:58:9: note: 'f' was declared here
   58 |     int f;
      |         ^
scales.cpp:38:21: warning: 'c' may be used uninitialized in this function [-Wmaybe-uninitialized]
   38 |     answerVector[2] = c;
      |     ~~~~~~~~~~~~~~~~^~~
scales.cpp:48:9: note: 'c' was declared here
   48 |     int c;
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...