# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
374639 | idk321 | Scales (IOI15_scales) | C++11 | 1 ms | 620 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);
auto it2 = r.begin();
it2++;
int x = getLightest(a, *r.begin(), *it2);
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();
int x = getLightest(*it3, *(++it3), *(++it3));
it3 = other.begin();
int y = getMedian(*it3, *(++it3), *(++it3));
other.erase(x);
other.erase(y);
int z = *other.begin();
other.erase(z);
int d = *other.begin();
int t1 = getNextLightest(x, y, z, d);
if (t1 == x)
{
int t2 = getLightest(x, y, d);
if (t2 == d)
{
res.push_back(d);
res.push_back(x);
res.push_back(y);
res.push_back(z);
} else
{
res.push_back(d);
res.push_back(x);
res.push_back(y);
res.push_back(z);
}
} else if (t1 == y)
{
res.push_back(x);
res.push_back(d);
res.push_back(y);
res.push_back(z);
} else if (t1 == z)
{
res.push_back(x);
res.push_back(y);
res.push_back(d);
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();
int x = getLightest(*it3, *(++it3), *(++it3));
it3 = other.begin();
int y = getMedian(*it3, *(++it3), *(++it3));
other.erase(x);
other.erase(y);
int last = *other.begin();
if (x == *r.begin())
{
it3 = other.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};
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |