답안 #767186

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
767186 2023-06-26T13:33:21 Z caganyanmaz 저울 (IOI15_scales) C++17
71.4286 / 100
1 ms 212 KB
#include <bits/stdc++.h>
#define pb push_back
#include "scales.h"
using namespace std;
//#define DEBUGGING
#ifdef DEBUGGING
#define debug(x) cout << #x << ": " << x << "\n";
#else
#define debug(x) 42
#endif

void init(int T)
{}

array<int, 3> find_other_values(int a, int b, int c)
{
        int a1 = 6 - a - c;
        int b2 = 4;
        while (b2 == b) b2++;
        int b3 = 4;
        while (b3 == b || b3 == b2) b3++;
        return array<int,3>({a1, b2, b3});
}

void orderCoins()
{
        vector<int> v(3);
        int a = getLightest(1, 2, 3);
        int b = getLightest(4, 5, 6);
        int c = 1;
        while (c == a) c++;
        auto [a1, b2, b3] = find_other_values(a, b, c);
        int m = getMedian(a, b, c);
        if (m == a)
        {
                v[0] = b, v[1] = a, v[2] = c;
                int bb2 = getNextLightest(b, a, c, b2);
                if (bb2 == b || bb2 == c)
                {
                        int aa1 = getNextLightest(a, b2, c, a1);
                        int bpos = -1, cpos = 2;
                        if (bb2 == b)
                        {
                                bpos = v.size();
                                v.pb(b2);
                        }
                        else // bb2 == c
                        {
                                bpos = 2;
                                v.insert(v.begin() + 2, b2);
                                cpos = 3;
                        }
                        if (aa1 == a)
                        v.pb(a1);
                        else if (aa1 == b2)
                                v.insert(v.begin() + bpos, a1);
                        else // aa1 == c
                                v.insert(v.begin() + cpos, a1);
                        int bb3 = getNextLightest(v[0], v[1], v[2], b3);
                        if (bb3 == v[1])
                                v.insert(v.begin() + 1, b3);
                        else if (bb3 == v[2])
                                v.insert(v.begin() + 2, b3);
                        else // This is where we get fucked (7th search possibility)
                        {
                                bb3 = getNextLightest(v[2], v[3], v[4], b3);
                                if (bb3 == v[2])
                                        v.pb(b3);
                                else if (bb3 == v[3])
                                        v.insert(v.begin() + 3, b3);
                                else // bb3 == v[4]
                                        v.insert(v.begin() + 4, b3);
                        }
                }
                else // bb2 == a
                {
                        v.insert(v.begin() + 1, b2);
                        int mx = getHeaviest(a1, c, b3);
                        if (mx == a1)
                        {
                                debug("bye");
                                int bb3 = getNextLightest(v[0], v[1], v[2], b3);
                                if (bb3 == v[1])
                                        v.insert(v.begin() + 1, b3);
                                else if (bb3 == v[2])
                                        v.insert(v.begin() + 2, b3);
                                else // Additional fuck-point
                                {

                                        bb3 = getHeaviest(c, b3, b);
                                        if (bb3 == c)
                                                v.insert(v.begin() + 3, b3);
                                        else
                                                v.insert(v.begin() + 4, b3);
                                }
                                v.pb(a1);
                        }
                        else if (mx == b3)
                        {
                                int mn = getLightest(a1, c, b3);
                                if (mn == a1)
                                        v.insert(v.begin() + 3, a1);
                                else
                                        v.pb(a1);
                                v.pb(b3);
                        }
                        else  // mx == c
                        {
                                int bb3 = getNextLightest(v[0], v[1], v[2], b3);
                                if (bb3 == v[1])
                                {
                                        v.insert(v.begin() + 1, b3);
                                        v.insert(v.begin() + 4, a1);
                                }
                                else if (bb3 == v[2])
                                {
                                        v.insert(v.begin() + 2, b3);
                                        v.insert(v.begin() + 4, a1);
                                }
                                else // Yet another fuck point
                                {
                                        int mx2 = getHeaviest(v[0], b3, a1);
                                        if (mx2 == b3)
                                        {
                                                v.insert(v.begin() + 3, b3);
                                                v.insert(v.begin() + 3, a1);
                                        }
                                        else
                                        {
                                                v.insert(v.begin() + 3, a1);
                                                v.insert(v.begin() + 3, b3);
                                        }
                                }
                        }
                }
        }
        if (m == b)
        {
                v[0] = a, v[1] = b, v[2] = c;
                int aa1 = getNextLightest(v[0], v[1], v[2], a1);
                if (aa1 == v[1])
                {
                        debug("hello");
                        v.insert(v.begin() + 1, a1);
                        int mx = getHeaviest(b, c, b2);
                        if (mx == b2)
                                v.pb(b2);
                        else // mx == c
                                v.insert(v.begin() + 3, b2);
                        int bb3 = getNextLightest(v[2], v[3], v[4], b3);
                        if (bb3 == v[2])
                                v.pb(b3);
                        else if (bb3 == v[3])
                                v.insert(v.begin() + 3, b3);
                        else
                                v.insert(v.begin() + 4, b3);
                }
                else // aa1 == v[0] || aa1 == v[2]
                {
                        debug("oi");
                        if (aa1 == v[0])
                        {
                                v.pb(a1);
                                debug(v.size());
                        }
                        else
                        {
                                v.insert(v.begin() + 2, a1);
                        }
                        int bb2 = getNextLightest(v[1], v[2], v[3], b2);
                        if (bb2 == v[1])
                                v.pb(b2);
                        else if (bb2 == v[2])
                                v.insert(v.begin() + 2, b2);
                        else
                                v.insert(v.begin() + 3, b2);
                        int bb3 = getNextLightest(v[1], v[2], v[3], b3);
                        if (bb3 == v[2])
                        {
                                v.insert(v.begin() + 2, b3);
                        }
                        else if (bb3 == v[3])
                        {
                                v.insert(v.begin() + 3, b3);
                        }
                        else // One last fuck-point
                        {
                                debug("haii");
                                debug(bb3);
                                debug(v[1]);
                                debug(v[2]);
                                debug(v[3]);
                                debug(v[4]);
                                bb3 = getNextLightest(v[2], v[3], v[4], b3);
                                debug(bb3);
                                //if (bb3 == v[3])
                                //{
                                //      debug(a, b, c, a1, b2, b3);
                                //}
                                //assert(bb3 != v[3]);
                                if (bb3 == v[2])
                                        v.pb(b3);
                                else // bb3 == v[4]
                                        v.insert(v.begin() + 4, b3);
                        }
                }
        }
        if (m == c)
        {
                v[0] = a, v[1] = c, v[2] = b;
                int aa1 = getNextLightest(v[0], v[1], v[2], a1);
                if (aa1 == v[0])
                        v.pb(a1);
                else if (aa1 == v[1])
                        v.insert(v.begin() + 1, a1);
                else
                        v.insert(v.begin() + 2, a1);
                int bb2 = getNextLightest(v[1], v[2], v[3], b2);
                if (bb2 == v[1])
                        v.pb(b2);
                else if (bb2 == v[2])
                        v.insert(v.begin() + 2, b2);
                else
                        v.insert(v.begin() + 3, b2);
                int bb3 = getNextLightest(v[2], v[3], v[4], b3);
                if (bb3 == v[2])
                        v.pb(b3);
                else if (bb3 == v[3])
                        v.insert(v.begin() + 3, b3);
                else
                        v.insert(v.begin() + 4, b3);
        }
        int result[6];
        for (int i =0; i< 6; i++)
                result[i] = v[i];
        answer(result);
}

Compilation message

scales.cpp: In function 'void init(int)':
scales.cpp:12:15: warning: unused parameter 'T' [-Wunused-parameter]
   12 | void init(int T)
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:44:46: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   44 |                                 bpos = v.size();
      |                                        ~~~~~~^~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:81:33: note: in expansion of macro 'debug'
   81 |                                 debug("bye");
      |                                 ^~~~~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:143:25: note: in expansion of macro 'debug'
  143 |                         debug("hello");
      |                         ^~~~~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:160:25: note: in expansion of macro 'debug'
  160 |                         debug("oi");
      |                         ^~~~~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:164:33: note: in expansion of macro 'debug'
  164 |                                 debug(v.size());
      |                                 ^~~~~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:188:33: note: in expansion of macro 'debug'
  188 |                                 debug("haii");
      |                                 ^~~~~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:189:33: note: in expansion of macro 'debug'
  189 |                                 debug(bb3);
      |                                 ^~~~~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:190:33: note: in expansion of macro 'debug'
  190 |                                 debug(v[1]);
      |                                 ^~~~~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:191:33: note: in expansion of macro 'debug'
  191 |                                 debug(v[2]);
      |                                 ^~~~~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:192:33: note: in expansion of macro 'debug'
  192 |                                 debug(v[3]);
      |                                 ^~~~~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:193:33: note: in expansion of macro 'debug'
  193 |                                 debug(v[4]);
      |                                 ^~~~~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:195:33: note: in expansion of macro 'debug'
  195 |                                 debug(bb3);
      |                                 ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 212 KB Output is partially correct
2 Partially correct 0 ms 212 KB Output is partially correct
3 Partially correct 0 ms 212 KB Output is partially correct
4 Partially correct 1 ms 212 KB Output is partially correct
5 Partially correct 0 ms 212 KB Output is partially correct
6 Partially correct 1 ms 212 KB Output is partially correct
7 Partially correct 1 ms 212 KB Output is partially correct
8 Partially correct 0 ms 212 KB Output is partially correct
9 Partially correct 0 ms 212 KB Output is partially correct
10 Partially correct 0 ms 212 KB Output is partially correct
11 Partially correct 0 ms 212 KB Output is partially correct
12 Partially correct 0 ms 212 KB Output is partially correct
13 Partially correct 0 ms 212 KB Output is partially correct
14 Partially correct 0 ms 212 KB Output is partially correct
15 Partially correct 0 ms 212 KB Output is partially correct
16 Partially correct 0 ms 212 KB Output is partially correct
17 Partially correct 0 ms 212 KB Output is partially correct
18 Partially correct 0 ms 212 KB Output is partially correct
19 Partially correct 0 ms 212 KB Output is partially correct
20 Partially correct 1 ms 212 KB Output is partially correct
21 Partially correct 0 ms 212 KB Output is partially correct
22 Partially correct 0 ms 212 KB Output is partially correct
23 Partially correct 1 ms 212 KB Output is partially correct
24 Partially correct 1 ms 212 KB Output is partially correct
25 Partially correct 0 ms 212 KB Output is partially correct
26 Partially correct 1 ms 212 KB Output is partially correct
27 Partially correct 0 ms 212 KB Output is partially correct
28 Partially correct 0 ms 212 KB Output is partially correct
29 Partially correct 1 ms 212 KB Output is partially correct
30 Partially correct 0 ms 212 KB Output is partially correct
31 Partially correct 0 ms 212 KB Output is partially correct
32 Partially correct 0 ms 212 KB Output is partially correct
33 Partially correct 0 ms 212 KB Output is partially correct
34 Partially correct 0 ms 212 KB Output is partially correct
35 Partially correct 1 ms 212 KB Output is partially correct
36 Partially correct 0 ms 212 KB Output is partially correct
37 Partially correct 0 ms 212 KB Output is partially correct
38 Partially correct 0 ms 212 KB Output is partially correct
39 Partially correct 0 ms 212 KB Output is partially correct
40 Partially correct 0 ms 212 KB Output is partially correct