Submission #588502

#TimeUsernameProblemLanguageResultExecution timeMemory
588502Nicolaikrob저울 (IOI15_scales)C++17
0 / 100
1 ms304 KiB
#include "scales.h"
#include <bits/stdc++.h>
using namespace std;

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

void orderCoins() {
    int a, b, c, d, e, f, t1, t2;
    a = getHeaviest(1, 2, 3);
    c = getLightest(1, 2, 3);
    for(int i=1;i<4;i++) if(i^a && i^c) b = i;
    d = getHeaviest(4, 5, 6);
    f = getLightest(4, 5, 6);
    for(int i=4;i<7;i++) if(i^d && i^f) e = i;
    t1 = getMedian(a, b, d);
    t2 = getMedian(c, e, f);

    if(t1 == a) {
        if(t2 == e) { int W[] = {f, e, c, b, a, d}; answer(W); }
        if(t2 == c) {
            t1 = getMedian(a, b, e);
            if(t1 == a) { int W[] = {f, c, b, a, e, d}; answer(W); }
            if(t1 == b) { int W[] = {f, c, e, b, a, d}; answer(W); }
            if(t1 == e) { int W[] = {f, c, b, e, a, d}; answer(W); }
        }
        if(t2 == f) {
            t1 = getNextLightest(a, e, f, b);
            if(t1 == a) { 
                t1 = getMedian(a, e, f);
                if(t1 == a) { int W[] = {c, f, b, a, e, d}; answer(W); }
                if(t1 == e) { int W[] = {c, f, e, b, a, d}; answer(W); }
                if(t1 == f) { int W[] = {c, b, a, f, e, d}; answer(W); }
            }
            if(t1 == e) { int W[] = {c, f, b, e, a, d}; answer(W); }
            if(t1 == f) {
                t1 = getHeaviest(a, e, f);
                if(t1 == a) { int W[] = {c, b, f, e, a, d}; answer(W); }
                if(t1 == e) { int W[] = {c, b, f, a, e, d}; answer(W); }
            }
        }
    }

    if(t1 == d) {
        if(t2 == e) { int W[] = {f, e, c, b, d, a}; answer(W); }
        if(t2 == c) {
            t1 = getHeaviest(b, e, f);
            if(t1 == b) { int W[] = {f, c, e, b, d, a}; answer(W); }
            if(t1 == e) { int W[] = {f, c, b, e, d, a}; answer(W); }
        }
        if(t2 == f) {
            t1 = getMedian(b, e, f);
            if(t1 == b) { int W[] = {c, f, b, e, d, a}; answer(W); }
            if(t1 == e) { int W[] = {c, f, e, b, d, a}; answer(W); }
            if(t1 == f) { int W[] = {c, b, f, e, d, a}; answer(W); }
        }
    }

    if(t1 == b) {
        if(t2 == c) { int W[] = {f, c, e, d, b, a}; answer(W); }
        if(t2 == e) {
            t1 = getHeaviest(c, d, f);
            if(t1 == c) { int W[] = {f, e, d, c, b, a}; answer(W); }
            if(t1 == d) { int W[] = {f, e, c, d, b, a}; answer(W); }
        }
        if(t2 == f) { int W[] = {c, f, e, d, b, a}; answer(W); }
    }
}

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:5:15: warning: unused parameter 'T' [-Wunused-parameter]
    5 | void init(int T) {
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:67:50: warning: 'e' may be used uninitialized in this function [-Wmaybe-uninitialized]
   67 |         if(t2 == f) { int W[] = {c, f, e, d, b, a}; answer(W); }
      |                                                  ^
scales.cpp:67:50: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
#Verdict Execution timeMemoryGrader output
Fetching results...