#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) {
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; 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;
}
}
}
void orderCoins() {
answer(ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |