# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
802715 | FatihSolak | Scales (IOI15_scales) | C++17 | 1 ms | 212 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) {
/* ... */
}
void orderCoins() {
mt19937 rng(chrono::steady_clock().now().time_since_epoch().count());
vector<int> ord = {1,2,3,4,5,6};
shuffle(ord.begin(),ord.end(),rng);
vector<int> v = {ord[0]};
for(int i = 2;i<=4;i+=2){
v[0] = getHeaviest(v[0],ord[i-1],ord[i]);
}
int tmp = ord[4 - (v[0] == ord[4])];
int val = getMedian(v[0],tmp,ord[5]);
if(val == tmp){
v = {ord[5],tmp,v[0]};
}
else if(val == ord[5]){
v = {tmp,ord[5],v[0]};
}
else{
v = {tmp,v[0],ord[5]};
}
for(int i = 1;i<=6;i++){
int num = ord[i-1];
bool ok = 1;
for(auto u:v){
if(u == num)
ok = 0;
}
if(!ok)
continue;
int vall = getNextLightest(v[v.size() - 3],v[v.size()-2],v[v.size()-1],num);
if(vall == v[v.size() - 3] && v.size() > 3){
vall = getNextLightest(v[0],v[1],v[2],num);
}
vector<int> tmpp;
for(auto u:v){
if(u == vall)
tmpp.push_back(num);
tmpp.push_back(u);
}
v = tmpp;
}
int W[] = {v[0],v[1],v[2],v[3],v[4],v[5]};
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |