# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1068501 | ArthuroWich | Scales (IOI15_scales) | C++17 | 1 ms | 604 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;
void init(int T) {
}
int mn[6][6][6];
int querymin(int a, int b, int c) {
vector<int> s = {a, b, c};
sort(s.begin(), s.end());
if (mn[a][b][c]) {
return mn[a][b][c];
} else {
mn[a][b][c] = getLightest(a, b, c);
return mn[a][b][c];
}
}
void orderCoins() {
int W[6];
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 6; j++) {
for (int k = 0; k < 6; k++) {
mn[i][j][k] = 0;
}
}
}
vector<int> a = {1, 2, 3, 4, 5, 6};
int j = 0;
while(a.size() != 3) {
int sh = querymin(a[0], a[1], a[2]);
if (a.size() == 4) {
if (sh != a[0]) {
sh = querymin(sh, a[0], a[3]);
} else {
sh = querymin(sh, a[1], a[3]);
}
} else if (a.size() == 5) {
sh = querymin(sh, a[3], a[4]);
} else if (a.size() == 6) {
sh = querymin(sh, a[3], a[4]);
if (sh != a[0]) {
sh = querymin(sh, a[0], a[5]);
} else {
sh = querymin(sh, a[1], a[5]);
}
}
W[j] = sh;
j++;
a.erase(find(a.begin(), a.end(), sh));
}
W[j] = querymin(a[0], a[1], a[2]);
j++;
W[j] = getMedian(a[0], a[1], a[2]);
j++;
a.erase(find(a.begin(), a.end(), W[j-1]));
a.erase(find(a.begin(), a.end(), W[j-2]));
W[j] = a[0];
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |