# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
520322 | silverfish | Scales (IOI15_scales) | C++17 | 2 ms | 1740 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;
#define pb push_back
const int INF = 1000;
int ans[999999][6];
int light(int a, int b, int c){
vector<int> v = {a,b,c};
sort(v.begin(), v.end());
return v[0];
}
int mid(int a, int b, int c){
vector<int> v = {a,b,c};
sort(v.begin(), v.end());
return v[1];
}
int heavy(int a, int b, int c){
vector<int> v = {a,b,c};
sort(v.begin(), v.end());
return v[2];
}
int nextl(int a, int b, int c, int d){
vector<int> v = {b,c,d};
sort(v.begin(), v.end());
if(heavy(b,c,d) < a) return light(b,c,d);
else return *upper_bound(v.begin(), v.end(), a);
}
void init(int T) {
vector<int> p = {1, 2, 3, 4, 5, 6};
do{
vector<int> q;
q.pb(nextl(p[2], p[3],p[5], p[0]));
q.pb(nextl(p[3], p[4],p[5], p[0]));
q.pb(nextl(p[5], p[0],p[4], p[1]));
q.pb(nextl(p[0], p[1],p[3], p[4]));
q.pb(nextl(p[4], p[2],p[5], p[1]));
q.pb(nextl(p[1], p[4],p[3], p[2]));
reverse(q.begin(), q.end());
int mul = 1, cur = 0;
for(int x : q){
cur += mul*x;
mul *= 10;
}
int v = 0;
mul = 1;
for(int i = 0; i < 6; ++i){
ans[cur][i] = p[i];
}
}while(next_permutation(p.begin(), p.end()));
return;
}
void orderCoins() {
int p[] = {1, 2, 3, 4, 5, 6};
vector<int> q;
q.pb(getNextLightest(p[2], p[3],p[5], p[0]));
q.pb(getNextLightest(p[3], p[4],p[5], p[0]));
q.pb(getNextLightest(p[5], p[0],p[4], p[1]));
q.pb(getNextLightest(p[0], p[1],p[3], p[4]));
q.pb(getNextLightest(p[4], p[2],p[5], p[1]));
q.pb(getNextLightest(p[1], p[4],p[3], p[2]));
reverse(q.begin(), q.end());
int mul = 1, cur = 0;
for(int x : q){
cur += mul*x;
mul *= 10;
}
//cout << cur << endl;
answer(ans[cur]);
return;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |