# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
302029 | square1001 | Scales (IOI15_scales) | C++14 | 1 ms | 384 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 <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
void init(int T) {
/* ... */
}
void orderCoins() {
int LA = getHeaviest(1, 2, 3);
int LB = getHeaviest(4, 5, 6);
int LC = getHeaviest(LA, LB, LA == 1 ? 2 : 1);
vector<int> rem1;
for(int i = 1; i <= 6; ++i) {
if(i != LC) {
rem1.push_back(i);
}
}
int LD = getHeaviest(rem1[0], rem1[1], rem1[2]);
int LE = getHeaviest(LD, rem1[3], rem1[4]);
vector<int> rem2;
for(int i = 1; i <= 6; ++i) {
if(i != LC && i != LE) {
rem2.push_back(i);
}
}
int LF = getHeaviest(rem2[0], rem2[1], rem2[2]);
vector<int> rem3;
for(int i = 1; i <= 6; ++i) {
if(i != LC && i != LE && i != LF) {
rem3.push_back(i);
}
}
int LG = getLightest(rem3[0], rem3[1], rem3[2]);
vector<int> rem4;
for(int i = 1; i <= 6; ++i) {
if(i != LC && i != LE && i != LG) {
rem4.push_back(i);
}
}
int LH = getMedian(rem4[0], rem4[1], rem4[2]);
vector<int> perm(6);
for(int i = 0; i < 6; ++i) {
perm[i] = i + 1;
}
do {
function<int(int, int, int)> lightest = [&](int va, int vb, int vc) {
vector<int> ord = { va, vb, vc };
sort(ord.begin(), ord.end(), [&](int i, int j) { return perm[i - 1] < perm[j - 1]; });
return ord[0];
};
function<int(int, int, int)> median = [&](int va, int vb, int vc) {
vector<int> ord = { va, vb, vc };
sort(ord.begin(), ord.end(), [&](int i, int j) { return perm[i - 1] < perm[j - 1]; });
return ord[1];
};
function<int(int, int, int)> heaviest = [&](int va, int vb, int vc) {
vector<int> ord = { va, vb, vc };
sort(ord.begin(), ord.end(), [&](int i, int j) { return perm[i - 1] < perm[j - 1]; });
return ord[2];
};
if(perm[LC - 1] == 6 && perm[LE - 1] == 5 && heaviest(rem2[0], rem2[1], rem2[2]) == LF && lightest(rem3[0], rem3[1], rem3[2]) == LG && median(rem4[0], rem4[1], rem4[2]) == LH) {
int W[6];
for(int i = 0; i < 6; ++i) {
W[perm[i] - 1] = i + 1;
}
answer(W);
return;
}
} while(next_permutation(perm.begin(), perm.end()));
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |