# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
800367 | erray | Scales (IOI15_scales) | C++17 | 1 ms | 212 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "scales.h"
#include<bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include "/home/ioi/codes/ioi15_d1/debug.h"
#else
#define debug(...) void(37)
#endif
template<typename T>
vector<T> inverse_fuck(T* a, int N) {
vector<T> res(N);
for (int i = 0; i < N; ++i) {
res[i] = a[i];
}
return res;
}
void init(int T) {
/* ... */
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//mt19937 rng(100);
void orderCoins() {
vector<int> rord(6);
iota(rord.begin(), rord.end(), 1);
//rord = {4, 6, 2, 1, 3, 5};
shuffle(rord.begin(), rord.end(), rng);
array<array<int, 3>, 2> ord{};
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < 3; ++j) {
ord[i][j] = rord[i * 3 + j];
}
debug(ord);
int mn = getLightest(ord[i][0], ord[i][1], ord[i][2]);
int med = getMedian(ord[i][0], ord[i][1], ord[i][2]);
for (int j = 1; j < 3; ++j) {
if (ord[i][j] == mn) {
swap(ord[i][0], ord[i][j]);
}
}
if (ord[i][1] != med) {
swap(ord[i][1], ord[i][2]);
}
}
debug(ord);
array<vector<int>, 4> ins;
int mx = -1;
for (auto x : ord[1]) {
int g = getNextLightest(ord[0][0], ord[0][1], ord[0][2], x);
int p = 0;
while (p < 3 && g != ord[0][p]) {
++p;
}
debug(x, g, p, mx);
if (mx > p) {
p = 3;
}
mx = p;
ins[p].push_back(x);
}
if (int(ins[0].size()) == 3) {
//bruh case
debug("BRUH");
int g = getNextLightest(ord[1][0], ord[1][1], ord[1][2], ord[0][0]);
debug(g);
//vector<int> aa;
if (g == ord[1][0] && getLightest(ord[0][0], ord[0][1], ord[1][2]) == ord[1][2]) {
//nothing
//swap(ins[0], ins[3]);
} else {
while (!ins[0].empty()) {
int add = ins[0].back();
ins[3].insert(ins[3].begin(), add);
ins[0].pop_back();
if (add == g) {
break;
}
}
}
}
vector<int> ans;
for (int i = 0; i < 4; ++i) {
for (auto x : ins[i]) {
ans.push_back(x);
}
if (i < 3) {
ans.push_back(ord[0][i]);
}
}
int W[] = {1, 2, 3, 4, 5, 6};
for (int i = 0; i < 6; ++i) {
W[i] = ans[i];
}
debug(ans);
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |