# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
286493 | dolphingarlic | 저울 (IOI15_scales) | C++14 | 1 ms | 512 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;
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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |