Submission #1153729

#TimeUsernameProblemLanguageResultExecution timeMemory
1153729wiiScales (IOI15_scales)C++20
24.74 / 100
1 ms328 KiB
#include "scales.h" #include <bits/stdc++.h> using namespace std; int seed = chrono::high_resolution_clock::now().time_since_epoch().count(); //int seed = 5; mt19937 rng(seed); int ans[6]; void sh(int id) { for (int i = 5; i > id; --i) ans[i] = ans[i - 1]; } void init(int T) { } void orderCoins() { for (int i = 0; i < 6; ++i) ans[i] = i + 1; shuffle(ans, ans + 6, rng); // for (int i = 0; i < 6; ++i) // cout << ans[i] << " \n"[i + 1 == 6]; int heavy = getHeaviest(ans[0], ans[1], ans[2]); heavy = getHeaviest(ans[3], ans[4], heavy); for (int i = 0; i < 5; ++i) if (ans[i] == heavy) swap(ans[i], ans[4]); // for (int i = 0; i < 6; ++i) // cout << ans[i] << " \n"[i + 1 == 6]; sort(ans, ans + 4, [&](int x, int y) { return getLightest(x, y, heavy) == x; }); // for (int i = 0; i < 6; ++i) // cout << ans[i] << " \n"[i + 1 == 6]; // cout << heavy << endl; int last = ans[5]; if (getLightest(ans[0], ans[1], last) == last) { sh(0); ans[0] = last; answer(ans); return; } for (int i = 0; i < 3; i += 2) { int k = getMedian(ans[i + 1], ans[i + 2], last); if (k == ans[i + 1]) { sh(i + 1); ans[i + 1] = last; break; } if (k == last) { sh(i + 2); ans[i + 2] = last; break; } } answer(ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...