# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
120193 | pavel | Scales (IOI15_scales) | C++14 | 3 ms | 384 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 <vector>
#include <cstdio>
#include "scales.h"
using namespace std;
void init(int T) {
/* ... */
}
void orderCoins() {
int W[] = {1, 2, 3, 4, 5, 6};
vector<vector<int>> v;
for(int i=1;i<=6;++i) v.push_back(vector<int>(1, i));
vector<int> sol;
while(true){
if(v.size()==3){
int a = getLightest(v[0].back(), v[1].back(), v[2].back());
int b = getMedian(v[0].back(), v[1].back(), v[2].back());
for(int i=0;i<3;++i){
if(a==v[i].back()){
sol.insert(sol.end(), v[i].begin(), v[i].end());
}
}
for(int i=0;i<3;++i){
if(b==v[i].back()){
sol.insert(sol.end(), v[i].begin(), v[i].end());
}
}
for(int i=0;i<3;++i){
if(v[i].back()!=a && v[i].back()!=b){
sol.insert(sol.end(), v[i].begin(), v[i].end());
}
}
break;
}else{
int med = getMedian(v[0].back(), v[1].back(), v[2].back());
vector<vector<int>> nm;
vector<int> medv;
for(auto i:v){
if(i.back()!=med){
nm.push_back(i);
}else{
medv=i;
}
}
int y = getNextLightest(nm[0].back(), nm[1].back(), nm[2].back(), med);
if(v.size()>4){
if(y==nm[nm.size()-2].back()) y = getNextLightest(y, nm[nm.size()-1].back(), nm[0].back(), med);
else y = getNextLightest(y, nm[nm.size()-1].back(), nm[nm.size()-2].back(), med);
}
vector<vector<int>> nxtv;
for(auto i:nm){
if(i.back()!=y){
nxtv.push_back(i);
}else{
medv.insert(medv.end(), i.begin(), i.end());
nxtv.push_back(medv);
}
}
v=nxtv;
}
}
for(int i=0;i<6;++i) W[i]=sol[i];
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |