Submission #286493

#TimeUsernameProblemLanguageResultExecution timeMemory
286493dolphingarlicScales (IOI15_scales)C++14
0 / 100
1 ms512 KiB
#include "scales.h"

#include <bits/stdc++.h>
using namespace std;

int med(int A, int B, int C, vector<int> p) {
    A--; B--; C--;
    if (p[B] < p[A] && p[A] < p[C]) return A + 1;
    if (p[C] < p[A] && p[A] < p[B]) return A + 1;
    if (p[A] < p[B] && p[B] < p[C]) return B + 1;
    if (p[C] < p[B] && p[B] < p[A]) return B + 1;
    return C + 1;
}

int hea(int A, int B, int C, vector<int> p) {
    A--; B--; C--;
    if (p[A] > p[B] && p[A] > p[C]) return A + 1;
    if (p[B] > p[A] && p[B] > p[C]) return B + 1;
    return C + 1;
}

int lig(int A, int B, int C, vector<int> p) {
    A--; B--; C--;
    if (p[A] < p[B] && p[A] < p[C]) return A + 1;
    if (p[B] < p[A] && p[B] < p[C]) return B + 1;
    return C + 1;
}

map<vector<int>, vector<int>> hsh;

void init(int T) {
    vector<int> p = {1, 2, 3, 4, 5, 6};
    do {
        int A = med(1, 3, 5, p), B = med(2, 4, 6, p);
        int C = hea(1, 2, 4, p), D = hea(3, 5, 6, p);
        int E = lig(1, 4, 6, p), F = lig(2, 3, 5, p);
        hsh[{A, B, C, D, E, F}] = p;
    } while (next_permutation(p.begin(), p.end()));
}

void orderCoins() {
    int A = getMedian(1, 3, 5), B = getMedian(2, 4, 6);
    int C = getHeaviest(1, 2, 4), D = getHeaviest(3, 5, 6);
    int E = getLightest(1, 4, 6), F = getLightest(2, 3, 5);
    vector<int> res = hsh[{A, B, C, D, E, F}];
    int W[6] = {res[0], res[1], res[2], res[3], res[4], res[5]};
    answer(W);
}

Compilation message (stderr)

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