# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
691686 | mychecksedad | Scales (IOI15_scales) | C++17 | 1 ms | 304 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>
#include <scales.h>
using namespace std;
void init(int T){
}
void answer(int W[]);
int getMedian(int A, int B, int C);
int getHeaviest(int A, int B, int C);
int getLightest(int A, int B, int C);
int getNextLightest(int A, int B, int C, int D);
void verase(int x, vector<int> &v){
for(int i = 0; i < v.size(); ++i){
if(v[i] == x){
v.erase(v.begin() + i);
return;
}
}
}
void vinsert(int pos, int val, vector<int> &v){
for(int i = v.size() - 1; i > pos; --i) v[i] = v[i - 1];
v[pos] = val;
}
void orderCoins() {
int W[6];
int mx = getHeaviest(1, 2, 3);
int val = getNextLightest(1, 2, 3, 4);
vector<int> v(7);
vector<bool> used(7);
v[3] = mx;
used[v[3]] = 1;
if(val == mx){
int mn = getLightest(1, 2, 3);
v[2] = 4;
v[0] = mn;
used[v[2]] = used[v[0]] = 1;
for(int i = 1; i <= 3; ++i) if(!used[i]) v[1] = i;
}else{
used[val] = 1;
int k;
for(int i = 1; i <= 3; ++i) if(!used[i]) k = i;
int med = getMedian(k, v[3], 4);
if(med == v[3]){
v[2] = v[3];
v[3] = 4;
v[0] = val;
v[1] = k;
}else if(med == 4){
v[0] = k;
v[1] = 4;
v[2] = val;
}else{
v[0] = 4;
v[1] = val;
v[2] = k;
}
}
int five1 = getMedian(v[0], v[1], 5);
if(five1 == v[0]){
vinsert(0, 5, v);
}else if(five1 == 5){
vinsert(1, 5, v);
}else{
int five2 = getMedian(v[2], v[3], 5);
if(five2 == v[3]){
vinsert(4, 5, v);
}else if(five2 == v[2]){
vinsert(2, 5, v);
}else{
vinsert(3, 5, v);
}
}
int six1 = getMedian(v[2], v[3], 6);
if(six1 == 6){
vinsert(3, 6, v);
}else if(six1 == v[2]){
int six2 = getMedian(v[0], v[1], 6);
if(six2 == v[0]){
vinsert(0, 6, v);
}else if(six2 == v[1]){
vinsert(2, 6, v);
}else{
vinsert(1, 6, v);
}
}else if(six1 == v[3]){
int six2 = getHeaviest(v[0], v[4], 6);
if(six2 == 6){
vinsert(5, 6, v);
}else{
vinsert(4, 6, v);
}
}
for(int i = 0; i < 6; ++i) W[i] = v[i];
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |