# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
287238 | shayan_p | Scales (IOI15_scales) | C++17 | 1 ms | 384 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 rets[6];
bool good = 0;
for(int i = 3; i < 6; i++){
int id = fnd(getNextLightest(arr[0], arr[1], arr[2], arr[i]));
rets[i] = id;
good|= id != 0;
}
if(!good){
if(getHeaviest(arr[4], arr[5], arr[0]) == arr[5])
rets[3] = rets[4] = rets[5] = 3;
}
int pt = 3, C = 0;
for(int i = 0; i <= 3; i++){
while(pt < 6 && rets[pt] == i)
ans[C++] = arr[pt], pt++;
if(i != 3)
ans[C++] = arr[i];
}
answer(ans);
// answer
// getHeaviest
// getLightest
// getMedian
// getNextLightest
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |