# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
744578 | Abrar_Al_Samit | Scales (IOI15_scales) | C++17 | 1 ms | 296 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;
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
void init(int T) {
}
void solve3(int *a) {
int mn = getLightest(*a, *(a+1), *(a+2));
if(mn==*(a+1)) swap(*a, *(a+1));
else if(mn==*(a+2)) swap(*a, *(a+2));
int mx = getHeaviest(*a, *(a+1), *(a+2));
if(mx==*(a+1)) swap(*(a+1), *(a+2));
}
void orderCoins() {
int a[6] = {1, 2, 3, 4, 5, 6};
shuffle(a, a+6, rng);
solve3(&a[0]);
solve3(&a[3]);
if(getLightest(a[0], a[1], a[3])==a[3]) {
swap(a[0], a[3]);
swap(a[1], a[4]);
swap(a[2], a[5]);
}
int before = getNextLightest(a[0], a[1], a[2], a[3]);
if(before==a[1]) {
swap(a[2], a[3]);
swap(a[1], a[2]);
} else if(before==a[2]) {
swap(a[2], a[3]);
} else {
answer(a);
return;
}
before = getNextLightest(a[1], a[2], a[3], a[4]);
if(before==a[2]) {
swap(a[3], a[4]);
swap(a[2], a[3]);
//take median
int med = getMedian(a[3], a[4], a[5]);
if(med==a[3]) {
swap(a[5], a[4]);
swap(a[4], a[3]);
} else if(med==a[5]) {
swap(a[5], a[4]);
}
} else if(before==a[3]) {
swap(a[3], a[4]);
//take max
int mx = getHeaviest(a[3], a[4], a[5]);
if(mx==a[4]) {
swap(a[4], a[5]);
}
} else {
answer(a);
return;
}
answer(a);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |