# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
831837 | qin | Scales (IOI15_scales) | C++14 | 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 orderCoins(){
vector<int> v1, v2;
int t1 = getLightest(1, 2, 3), t3 = getHeaviest(1, 2, 3);
int tmp = 1;
for(int i = 1; i <= 3; ++i) if(i != t1 && i != t3) tmp = i;
v1 = {t3, tmp, t1};
t1 = getLightest(4, 5, 6), t3 = getHeaviest(4, 5, 6);
for(int i = 4; i <= 6; ++i) if(i != t1 && i != t3) tmp = i;
v2 = {t3, tmp, t1};
vector<int> wynik;
while(!v1.empty() || !v2.empty()){
if(v1.size() == (size_t) 1 && v2.size() == (size_t) 1){
int tmp = getMedian(wynik[0], v1.back(), v2.back());
if(v1.back() == tmp) wynik.emplace_back(v1.back()), wynik.emplace_back(v2.back());
else wynik.emplace_back(v2.back()), wynik.emplace_back(v1.back());
v1.pop_back(), v2.pop_back();
continue;
}
if(v1.empty()) while(!v2.empty()) wynik.emplace_back(v2.back()), v2.pop_back();
if(v2.empty()) while(!v1.empty()) wynik.emplace_back(v1.back()), v1.pop_back();
if(v1.size() && v2.size()){
if(v2.size() > v1.size()) swap(v1, v2);
int tmp = getLightest(v1.back(), v2.back(), v1[0]);
if(v1.back() == tmp) wynik.emplace_back(v1.back()), v1.pop_back();
else wynik.emplace_back(v2.back()), v2.pop_back();
}
}
int w[6];
for(int i = 0; i < 6; ++i) w[i] = wynik[i];
answer(w);
}
void init(int T){
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |