# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
759436 | pawned | Scales (IOI15_scales) | C++17 | 1 ms | 300 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;
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
int lightest(int x, int y, int z) {
int res = getLightest(x + 1, y + 1, z + 1) - 1;
return res;
}
int median(int x, int y, int z) {
int res = getMedian(x + 1, y + 1, z + 1) - 1;
return res;
}
int heaviest(int x, int y, int z) {
int res = getHeaviest(x + 1, y + 1, z + 1) - 1;
return res;
}
void init(int T) {
/* ... */
}
void orderCoins() {
bool used[6] = {false};
//------------------------
int x1 = lightest(0, 1, 2);
x1 = lightest(x1, 3, 4);
if (x1 != 4)
x1 = lightest(x1, 4, 5);
else
x1 = lightest(x1, 3, 5);
used[x1] = true;
// cout<<"x1: "<<x1<<endl;
// now x1 is the lighest
//------------------------
vi un; // unused
for (int j = 0; j < 6; j++) {
if (!used[j])
un.pb(j);
}
int x2 = lightest(un[0], un[1], un[2]);
x2 = lightest(x2, un[3], un[4]);
used[x2] = true;
// cout<<"x2: "<<x2<<endl;
// now x2 is the second lightest
//------------------------
un.clear();
for (int j = 0; j < 6; j++) {
if (!used[j])
un.pb(j);
}
int x6 = heaviest(un[0], un[1], un[2]);
// this if-else is just to get rid of duplicates
if (x6 != un[0])
x6 = heaviest(x6, un[0], un[3]);
else
x6 = heaviest(x6, un[1], un[3]);
used[x6] = true;
// cout<<"x6: "<<x6<<endl;
// now x6 is the heaviest
//------------------------
un.clear();
for (int j = 0; j < 6; j++) {
if (!used[j])
un.pb(j);
}
int x5 = heaviest(un[0], un[1], un[2]);
used[x5] = true;
// cout<<"x5: "<<x5<<endl;
// now x6 is the second heaviest
//------------------------
un.clear();
for (int j = 0; j < 6; j++) {
if (!used[j])
un.pb(j);
}
int x3 = lightest(un[0], un[1], x6);
int x4;
if (x3 == un[0])
x4 = un[1];
else
x4 = un[0];
// cout<<"x3: "<<x3<<endl;
// cout<<"x4: "<<x4<<endl;
//------------------------
int W[] = {x1 + 1, x2 + 1, x3 + 1, x4 + 1, x5 + 1, x6 + 1};
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |