Submission #1066296

#TimeUsernameProblemLanguageResultExecution timeMemory
1066296ptf62331Scales (IOI15_scales)C++14
0 / 100
1 ms604 KiB
#include "scales.h" #include<bits/stdc++.h> using namespace std; #define vec vector void init(int T) { /* ... */ } void orderCoins() { /* ... */ int w[] = {1, 2, 3, 4, 5, 6}; vec<int> right_part{4, 5, 6}; vec<int> left_part{1,2,3}; int x = getHeaviest(1, 2, 3); left_part.erase(find(left_part.begin(), left_part.end(), x)); int y = getHeaviest(4, 5, 6); right_part.erase(find(right_part.begin(), right_part.end(), y)); int z = getNextLightest(y, left_part[0], left_part[1], x); vec<int> cur{}; vec<int> rem{}; if(z != y) { swap(x, y); if(z == left_part[1]) { swap(left_part[0], left_part[1]); } int med = getMedian(left_part[0], left_part[1], x); if(med == left_part[0]) { left_part.insert(left_part.begin()+0, x); } else if(med == x) { left_part.insert(left_part.begin()+1, x); } else { assert(med == left_part[1]); left_part.insert(left_part.begin()+2, x); } cur = left_part; left_part.push_back(y); rem = right_part; } else { int med = getMedian(left_part[0], left_part[1], x); if(med != left_part[1]) { swap(left_part[0], left_part[1]); } cur = left_part; cur.push_back(x); cur.push_back(y); rem = right_part; } assert(rem.size() == 2); // y > x //cur is sorted // for rem we know only they're less than two last int a = getLightest(rem[0], rem[1], cur[0]); if(a==cur[0]) { int b = getLightest(rem[0], rem[1], cur[1]); if(b==cur[1]) { int c = getLightest(rem[0], rem[1], cur[2]); if(c==rem[1]) swap(rem[0], rem[1]); cur.insert(cur.begin()+2, rem[1]); cur.insert(cur.begin()+2, rem[2]); rem = {}; } else { if(b == rem[1]) swap(rem[0], rem[1]); cur.insert(cur.begin()+1, rem[0]); rem.erase(rem.begin()); int c = getLightest(rem[0], cur[1], cur[2]); if(c == cur[1]) { cur.insert(cur.begin()+3, rem[0]); rem = {}; } else { cur.insert(cur.begin()+2, rem[0]); rem = {}; } } } else { cur.insert(cur.begin()+0, a); rem.erase(find(rem.begin(), rem.end(), a)); int b = getMedian(cur[1], cur[2], rem[0]); if(b==rem[0]) { cur.insert(cur.begin()+2, rem[0]); } else if(b==cur[2]) { cur.insert(cur.begin()+3, rem[0]); } else { assert(b==cur[1]); cur.insert(cur.begin()+1, rem[0]); } rem = {}; } assert(cur.size() == 6); for(int i = 0; i<6; i++) { w[i] = cur[i]; cerr << w[i] << ' '; } cerr << '\n'; answer(w); }

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:7:15: warning: unused parameter 'T' [-Wunused-parameter]
    7 | void init(int T) {
      |           ~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...