# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
801907 | _martynas | Scales (IOI15_scales) | C++11 | 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 "scales.h"
#include <bits/stdc++.h>
using namespace std;
void init(int T) {
/* ... */
}
void orderCoins() {
/* ... */
int first_half_light = getLightest(1, 2, 3);
int first_half_heavy = getHeaviest(1, 2, 3);
int first_half_mid = 1^2^3^first_half_light^first_half_heavy;
int second_half_light = getLightest(4, 5, 6);
int second_half_heavy = getHeaviest(4, 5, 6);
int second_half_mid = 4^5^6^second_half_light^second_half_heavy;
vector<char> order = {'L', 'L', 'L'}; // L - first half, R - second half
vector<int> check = {4, 5, 6};
auto insert_after = [](vector<char> &v, int cnt) {
if(cnt == 3) {
v.push_back('R');
}
else {
for(int i = 0; i < v.size(); i++) {
if(cnt == 0) {
v.insert(v.begin()+i, 'R');
return;
}
if(v[i] == 'L') cnt--;
}
}
};
for(int x : check) {
int resp = getNextLightest(first_half_light, first_half_mid, first_half_heavy, x);
if(resp == first_half_light) {
int resp1 = getLightest(first_half_light, first_half_mid, x);
if(resp1 == x) {
insert_after(order, 0);
}
else {
insert_after(order, 3);
}
}
else {
if(resp == first_half_mid) {
insert_after(order, 1);
}
else {
insert_after(order, 2);
}
getLightest(1, 2, 3); // do nothing function to have constant Q
}
}
int W[6];
vector<int> first_half = {first_half_light, first_half_mid, first_half_heavy};
vector<int> second_half = {second_half_light, second_half_mid, second_half_heavy};
for(int i = 0, first_it = 0, second_it = 0; i < 6; i++) {
if(order[i] == 'L') {
W[i] = first_half[first_it++];
}
else {
W[i] = second_half[second_it++];
}
}
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |