# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
287224 | shayan_p | Scales (IOI15_scales) | C++17 | 1 ms | 416 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.
// Oh damn! Suddenly you're free to fly...
#include<bits/stdc++.h>
#include "scales.h"
#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e5 + 10, mod = 1e9 + 7, inf = 1e9 + 10;
void init(int T){
srand(time(0));
}
void orderCoins(){
int arr[6] = {1, 2, 3, 4, 5, 6};
int ans[6];
random_shuffle(arr, arr + 6);
auto fnd = [&](int x){
for(int i = 0; i < 6; i++)
if(arr[i] == x)
return i;
assert(0);
};
swap(arr[0], arr[fnd(getLightest(arr[0], arr[1], arr[2]))]);
swap(arr[2], arr[fnd(getHeaviest(arr[0], arr[1], arr[2]))]);
swap(arr[3], arr[fnd(getLightest(arr[3], arr[4], arr[5]))]);
swap(arr[5], arr[fnd(getHeaviest(arr[3], arr[4], arr[5]))]);
int pt1 = 0, pt2 = 3, C = 0;
auto cmp = [&](int a, int b){
if(a <= 1)
return getLightest(arr[a], arr[a+1], arr[b]) == arr[a];
else
return getHeaviest(arr[a-1], arr[a], arr[b]) == arr[b];
};
while(C < 6){
if(pt2 == 6 || (pt1 != 3 && cmp(pt1, pt2)))
ans[C++] = arr[pt1++];
else
ans[C++] = arr[pt2++];
}
answer(ans);
// answer
// getHeaviest
// getLightest
// getMedian
// getNextLightest
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |