# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
782860 | ymm | 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>
#define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (l); --x)
typedef std::pair<int,int> pii;
typedef long long ll;
using namespace std;
void init(int T) {
/* ... */
}
void lstmx(int &a, int &b, int &c)
{
int x = getHeaviest(a, b, c);
if (a == x)
swap(a, c);
if (b == x)
swap(b, c);
}
void fstmn(int &a, int &b, int &c)
{
int x = getLightest(a, b, c);
if (c == x)
swap(a, c);
if (b == x)
swap(a, b);
}
void mv(int W[], int i, int j)
{
int x = W[i];
memmove(W+i, W+i+1, (5-i)*4);
memmove(W+j+1, W+j, (5-j)*4);
W[j] = x;
}
mt19937_64 rd(time(0));
void orderCoins() {
/* ... */
int W[] = {1, 2, 3, 4, 5, 6};
shuffle(W, W+6, rd);
fstmn(W[0], W[1], W[2]);
lstmx(W[0], W[1], W[2]);
fstmn(W[3], W[4], W[5]);
lstmx(W[3], W[4], W[5]);
int x = getNextLightest(W[0], W[1], W[2], W[3]);
int y = getNextLightest(W[0], W[1], W[2], W[5]);
if (x == W[0] && y == W[0]) {
if (getLightest(W[0], W[3], W[4]) != W[0]) {
swap(W[0], W[3]);
swap(W[1], W[4]);
swap(W[2], W[5]);
}
answer(W);
return;
}
int z = getNextLightest(W[0], W[1], W[2], W[4]);
int a[3] = {x, z, y};
Loop (i,0,3) {
Loop (j,0,3) {
if (a[i] == W[j]) {
a[i] = j;
break;
}
}
}
//Loop (i,0,6)
// cerr << W[i] << ' ';
//cerr << '\n';
//Loop (i,0,3)
// cerr << a[i] << ' ';
//cerr << '\n';
mv(W, 5, a[2]);
mv(W, 5, a[1]);
mv(W, 5, a[0]);
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |