# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
374958 | idk321 | Scales (IOI15_scales) | C++11 | 1 ms | 492 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;
typedef long long ll;
void init(int T) {
/* ... */
}
void orderCoins() {
/* ... */
int a = getLightest(1, 2, 3);
int b = getLightest(4, 5, 6);
set<int> l = {1, 2, 3};
set<int> r = {4, 5, 6};
l.erase(a);
r.erase(b);
vector<int> res;
int c = getLightest(*l.begin(), a, b);
res.push_back(c);
if (c == a)
{
swap(a, b);
swap(l, r);
}
auto it2 = r.begin();
it2++;
int x = getLightest(a, *r.begin(), *it2);
int oldX = x;
res.push_back(x);
if (x == a)
{
set<int> other;
for (int i : l) other.insert(i);
for (int i : r) other.insert(i);
auto it3 = other.begin();
vector<int> v(3);
v[0] = *it3;
it3++;
v[1] = *it3;
it3++;
v[2] = *it3;
int x = getLightest(v[0], v[1], v[2]);
other.erase(x);
int y = *other.begin();
other.erase(y);
int z = *other.begin();
other.erase(z);
int d = *other.begin();
int t1 = getNextLightest(oldX, x, y, d);
if (t1 == x)
{
res.push_back(d);
res.push_back(x);
int t2 = getMedian(oldX, y, z);
if (t2 == y)
{
res.push_back(y);
res.push_back(z);
} else
{
res.push_back(z);
res.push_back(y);
}
} else
{
if (t1 == oldX) swap(d, y);
res.push_back(x);
int t2 = getMedian(y, z, d);
if (t2 == z)
{
res.push_back(d);
res.push_back(z);
res.push_back(y);
} else if (t2 == d)
{
res.push_back(z);
res.push_back(d);
res.push_back(y);
} else
{
res.push_back(d);
res.push_back(y);
res.push_back(z);
}
}
} else
{
r.erase(x);
set<int> other;
for (int i : l) other.insert(i);
for (int i : r) other.insert(i);
auto it3 = other.begin();
vector<int> v(3);
for (int i = 0; i < 3; i++)
{
v[i] = *it3;
it3++;
}
int x = getLightest(v[0], v[1], v[2]);
int y = getMedian(v[0], v[1], v[2]);
other.erase(x);
other.erase(y);
int last = *other.begin();
if (x == *r.begin())
{
int z = getLightest(x, a, y);
if (z == a)
{
res.push_back(a);
res.push_back(x);
res.push_back(y);
res.push_back(last);
} else
{
res.push_back(x);
res.push_back(a);
res.push_back(y);
res.push_back(last);
}
} else
{
res.push_back(a);
res.push_back(x);
res.push_back(y);
res.push_back(last);
}
}
int W[] = {1, 2, 3, 4, 5, 6};
for (int i = 0; i < 6; i++) W[i] = res[i];
answer(W);
}
/*
1
1 3 2 5 4 6
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |