# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
128059 | Sorting | Scales (IOI15_scales) | C++14 | 0 ms | 0 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 <bits/stdc++.h>
using namespace std;
void answer(int *W);
int getHeaviest(int A, int B, int C);
int getLightest(int A, int B, int C);
int getMedian(int A, int B, int C);
int getNextLightest(int A, int B, int C, int D);
void init(int t){
}
vector<int> other(vector<int> v){
vector<int> ans;
for(int i = 1; i <= 6; i++){
bool ok = true;
for(int x: v){
if(x == i){
ok = false;
}
}
if(ok){
ans.push_back(i);
}
}
return ans;
}
void erase(vector<int> &a, int x){
for(int i = 0; i < (int)a.size(); i++){
if(a[i] == x){
for(int j = i; j < (int)a.size() - 1; j++){
a[j] = a[j + 1];
}
a.pop_back();
return;
}
}
}
int ans[6];
void orderCoins(){
vector<int> a = {1, 2, 3, 4, 5, 6};
int c1 = getLightest(1, 2, 3);
int c2 = getLightest(4, 5, 6);
int c3 = getLightest(c1, c2, other(vector<int>{c1, c2})[0]);
ans[0] = c3;
erase(a, c3);
int c4, c5;
if(c3 == c1){
vector<int> v;
for(int i = 1; i <= 4; i++){
if(c1 == i){
continue;
}
v.push_back(i);
}
c4 = getLightest(v[0], v[1], v[2]);
c5 = c2;
}
else{
vector<int> v;
for(int i = 3; i <= 6; i++){
if(c2 == i){
continue;
}
v.push_back(i);
}
c4 = getLightest(v[0], v[1], v[2]);
c5 = c1;
}
int c6 = getLightest(c4, c5, other(vector<int>{c4, c5, c3})[0]);
ans[1] = c6;
int c7 = c4 + c5 - c6;
vector<int> v1 = other(vector<int>{c4, c5, c3});
int c8 = getLightest(v1[0], v1[1], v1[2]);
int c9 = getLightest(c8, c7, other(vector<int>{c4, c5, c3, c8})[0]);
ans[2] = c9;
vector<int> v2 = other(vector<int>{c3, c6, c9});
int c10 = getLightest(v2[0], v2[1], v2[2]);
int c11 = getHeaviest(v2[0], v2[1], v2[2]);
ans[3] = c10;
ans[5] = c11;
ans[4] = v2[0] + v2[1] + v2[2] - c10 - c11;
answer(ans);
}