Submission #767144

#TimeUsernameProblemLanguageResultExecution timeMemory
767144caganyanmazScales (IOI15_scales)C++17
0 / 100
1 ms212 KiB
#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); debug(a); debug(b); debug(c); debug(m); if (m == a) { v[0] = b, v[1] = a, v[2] = c; int bb2 = getNextLightest(b, a, c, b2); debug(bb2); 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 { debug("hi"); v.insert(v.begin() + 1, b2); int mx = getHeaviest(a1, c, b3); if (mx == 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 v.insert(v.begin() + 3, b3); v.pb(a1); } else if (mx == b3) { int mn = getLightest(a1, c, b3); if (mn == a1) v.insert(v.begin() + 3, a); 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); else if (bb3 == v[2]) v.insert(v.begin() + 2, b3); 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) { debug(a1); v[0] = a, v[1] = b, v[2] = c; debug(v[0]); debug(v[1]); debug(v[2]); int aa1 = getNextLightest(v[0], v[1], v[2], a1); debug(aa1); if (aa1 == v[1]) { 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() + 2, b2); int bb3 = getNextLightest(v[2], v[3], v[4], b3); if (bb3 == v[2]) v.pb(b3); 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); } debug(b2); debug(b3); int bb2 = getNextLightest(v[1], v[2], v[3], b2); debug(v.size()); debug(bb2); if (bb2 == v[1]) { debug("why"); 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 { bb3 = getNextLightest(v[2], v[3], v[4], 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 (stderr)

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:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:34:9: note: in expansion of macro 'debug'
   34 |         debug(a);
      |         ^~~~~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:35:9: note: in expansion of macro 'debug'
   35 |         debug(b);
      |         ^~~~~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:36:9: note: in expansion of macro 'debug'
   36 |         debug(c);
      |         ^~~~~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:37:9: note: in expansion of macro 'debug'
   37 |         debug(m);
      |         ^~~~~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:42:17: note: in expansion of macro 'debug'
   42 |                 debug(bb2);
      |                 ^~~~~
scales.cpp:49:46: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   49 |                                 bpos = v.size();
      |                                        ~~~~~~^~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:82:25: note: in expansion of macro 'debug'
   82 |                         debug("hi");
      |                         ^~~~~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:131:17: note: in expansion of macro 'debug'
  131 |                 debug(a1);
      |                 ^~~~~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:133:17: note: in expansion of macro 'debug'
  133 |                 debug(v[0]);
      |                 ^~~~~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:134:17: note: in expansion of macro 'debug'
  134 |                 debug(v[1]);
      |                 ^~~~~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:135:17: note: in expansion of macro 'debug'
  135 |                 debug(v[2]);
      |                 ^~~~~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:137:17: note: in expansion of macro 'debug'
  137 |                 debug(aa1);
      |                 ^~~~~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:156:25: note: in expansion of macro 'debug'
  156 |                         debug("oi");
      |                         ^~~~~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:160:33: note: in expansion of macro 'debug'
  160 |                                 debug(v.size());
      |                                 ^~~~~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:166:25: note: in expansion of macro 'debug'
  166 |                         debug(b2);
      |                         ^~~~~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:167:25: note: in expansion of macro 'debug'
  167 |                         debug(b3);
      |                         ^~~~~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:169:25: note: in expansion of macro 'debug'
  169 |                         debug(v.size());
      |                         ^~~~~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:170:25: note: in expansion of macro 'debug'
  170 |                         debug(bb2);
      |                         ^~~~~
scales.cpp:9:18: warning: statement has no effect [-Wunused-value]
    9 | #define debug(x) 42
      |                  ^~
scales.cpp:173:33: note: in expansion of macro 'debug'
  173 |                                 debug("why");
      |                                 ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...