Submission #302029

#TimeUsernameProblemLanguageResultExecution timeMemory
302029square1001Scales (IOI15_scales)C++14
55.56 / 100
1 ms384 KiB
#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)

scales.cpp: In function 'void init(int)':
scales.cpp:7:15: warning: unused parameter 'T' [-Wunused-parameter]
    7 | void init(int T) {
      |           ~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...