# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
386673 | Keshi | Scales (IOI15_scales) | C++17 | 2 ms | 512 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.
//In the name of God
#include <bits/stdc++.h>
#include "scales.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
const ll maxn = 2e5 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout);
#define pb push_back
#define Mp make_pair
#define F first
#define S second
#define Sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()
#define g1 getLightest
#define g2 getMedian
#define g3 getHeaviest
#define g4 getNextLightest
void init(int T) {
srand(time(NULL));
}
int a[] = {1, 2, 3, 4, 5, 6};
int b[] = {1, 2, 3, 4, 5, 6};
void Do(ll i, ll j){
b[i] = a[i];
for(ll o = i; o > j; o--){
swap(b[o], b[o - 1]);
}
}
void orderCoins(){
random_shuffle(a, a + 6);
b[0] = g1(a[0], a[1], a[2]);
b[1] = g2(a[0], a[1], a[2]);
b[2] = g3(a[0], a[1], a[2]);
// solve b[3]
ll x = g4(b[0], b[1], b[2], a[3]);
if(x == b[0]){
if(g1(b[0], b[1], a[3]) == a[3]) Do(3, 0);
else Do(3, 3);
}
else{
if(x == b[1]) Do(3, 1);
else Do(3, 2);
}
// solve b[4]
x = g4(b[0], b[1], b[2], a[4]);
if(x != b[0]){
if(x == b[1]) Do(4, 1);
else Do(4, 2);
}
else{
x = g4(b[0], b[1], b[3], a[4]);
if(x == b[3]) Do(4, 3);
else{
if(g1(b[0], b[1], a[4]) == a[4]) Do(4, 0);
else Do(4, 4);
}
}
// solve b[5]
x = g4(b[0], b[1], b[2], a[5]);
if(x != b[0]){
if(x == b[1]) Do(5, 1);
else Do(5, 2);
}
else{
x = g4(b[0], b[3], b[4], a[5]);
if(x != b[0]){
if(x == b[3]) Do(5, 3);
else Do(5, 4);
}
else{
if(g1(b[0], b[1], a[5]) == a[5]) Do(5, 0);
else Do(5, 5);
}
}
answer(b);
}
/*int main(){
fast_io;
return 0;
}
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |