Submission #484763

#TimeUsernameProblemLanguageResultExecution timeMemory
484763imachugScales (IOI15_scales)C++17
45.45 / 100
1 ms204 KiB
#include "scales.h" #include <bits/stdc++.h> using namespace std; void init(int T) { /* ... */ } void order3(int a, int b, int c, int* w) { w[0] = getLightest(a, b, c); w[1] = getMedian(a, b, c); w[2] = a + b + c - w[0] - w[1]; } void order4(int a, int b, int c, int d, int* w) { // getNextLightest(a, b, c, d) int max1 = getHeaviest(a, b, c); int max2 = getHeaviest(a, b, d); int max = max1 == max2 ? max1 : getHeaviest(a, c, d); int i = 0; for(int x: {a, b, c, d}) { if(x != max) { w[i++] = x; } } w[i++] = max; order3(w[0], w[1], w[2], w); } void order6(int a, int b, int c, int d, int e, int f, int* w) { int w1[3]; int w2[3]; order3(a, b, c, w1); order3(d, e, f, w2); int max = getHeaviest(w1[0], w1[2], w2[2]); merge(w1, w1 + 3, w2, w2 + 3, w, [&](int i, int j) { if(i == max) { return false; } else if(j == max) { return true; } return getLightest(i, j, max) == i; }); return; // int max1 = getHeaviest(a, b, c); // int max2 = getHeaviest(d, e, f); // int max = getHeaviest(max1, max2, max1 == a ? b : a); // int min1 = getLightest(a, b, c); // int min2 = getLightest(d, e, f); // int min = getLightest(min1, min2, min1 == a ? b : a); // int i = 0; // w[i++] = min; // for(int x: {a, b, c, d, e, f}) { // if(x != min && x != max) { // w[i++] = x; // } // } // w[i++] = max; // order4(w[1], w[2], w[3], w[4], w + 1); } void orderCoins() { int W[6]; order6(1, 2, 3, 4, 5, 6, W); answer(W); return; // int max1 = getHeaviest(1, 2, 3); // // Is one of the halves strictly less than the other half? // if(getNextLightest(4, 5, 6, max1) == getLightest(4, 5, 6)) { // // Seems so. Order the two halves separately // int W[6]; // order3(1, 2, 3, W); // order3(4, 5, 6, W + 3); // if(getLightest(W[0], W[1], W[3]) == W[3]) { // // The second half goes before the first half // swap(W[0], W[3]); // swap(W[1], W[4]); // swap(W[2], W[5]); // } // answer(W); // return; // } // int max2 = getHeaviest(4, 5, 6); // int max3 = max1 == 1 ? 2 : 1; // int max = getHeaviest(max1, max2, max3); // int W[] = {1, 2, 3, 4, 5, 6}; // swap(W[5], W[max - 1]); // stable_sort(W, W + 5, [&](int i, int j) { // return getLightest(i, j, max) == i; // }); // answer(W); }

Compilation message (stderr)

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