# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
619591 | mdn2002 | Scales (IOI15_scales) | C++14 | 1 ms | 212 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 l1 = getLightest ( 1 , 2 , 3 ) , l2 = getLightest ( 4 , 5 , 6 ) , l , n = 6;
map < int , int > ans;
for ( int i = 1 ; i <= n ; i ++ )
{
if ( i != l1 && i != l2 )
{
l = getLightest ( l1 , l2 , i );
ans [1] = l;
break;
}
}
vector < int > nxt;
int cn;
if ( l1 == l )
{
cn = l2;
for ( int i = 1 ; i <= 3 ; i ++ )
{
if ( l != i ) nxt . push_back ( i );
}
}
if ( l2 == l )
{
cn = l1;
for ( int i = 4 ; i <= 6 ; i ++ )
{
if ( l != i ) nxt . push_back ( i );
}
}
int l22 = getLightest ( nxt [0] , nxt [1] , cn );
ans [2] = l22;
if ( l22 == cn )
{
set < int > s;
for ( int i = 1 ; i <= 6 ; i ++ )
{
if ( i == l || i == l22 ) continue;
s . insert ( i );
}
int l33 = getNextLightest ( l , l22 , * s . begin () , * -- s . end () );
int a = * s . begin () , b = * -- s . end () , c = -1 , d;
if ( l33 == a ) swap ( a , b );
for ( int i = 1 ; i <= 6 ; i ++ )
{
if ( i == a || i == b || i == l || i == l22 ) continue;
if ( c == -1 ) c = i;
else d = i;
}
int ltt = getLightest ( a , c , d );
ans [3] = ltt;
if ( ltt == a )
{
int lttt = getLightest ( b , c , d );
int hvvv = getHeaviest ( b , c , d );
ans [4] = lttt , ans [6] = hvvv;
for ( int i = 1 ; i <= n ; i ++ )
{
if ( i == lttt || i == hvvv ) continue;
if ( i != b && i != c && i != d ) continue;
ans [5] = i;
}
}
else
{
int hvv = getHeaviest ( a , c , d );
if ( ltt == c ) c = d;
if ( hvv == a )
{
ans [4] = c;
ans [5] = a;
ans [6] = b;
}
else
{
int middd = getMedian ( a , b , c );
if ( middd == a )
{
ans [4] = c;
ans [5] = a;
ans [6] = b;
}
if ( middd == b )
{
ans [4] = a;
ans [5] = b;
ans [6] = c;
}
if ( middd == c )
{
ans [4] = a;
ans [5] = c;
ans [6] = b;
}
}
}
}
else
{
int mid , fuck;
if ( nxt [0] == l22 ) nxt . erase ( nxt . begin () );
if ( nxt [1] == l22 ) nxt . pop_back ();
for ( int i = 1 ; i <= n ; i ++ )
{
if ( i == l ) continue;
if ( i == l22 ) continue;
if ( i == nxt [0] ) continue;
if ( i == cn ) continue;
mid = getMedian ( nxt [0] , cn , i );
if ( mid == nxt [0] )
{
ans [3] = cn;
fuck = i;
}
if ( mid == cn )
{
ans [3] = nxt [0];
ans [4] = cn;
}
if ( mid == i )
{
ans [3] = cn;
fuck = nxt [0];
nxt [0] = i;
}
break;
}
set < int > s;
for ( int i = 1 ; i <= 6 ; i ++ ) s . insert ( i );
for ( int i = 1 ; i <= 4 ; i ++ )
{
if ( ans [i] == 0 ) break;
s . erase ( s . lower_bound ( ans [i] ) );
}
int midd;
if ( s . size () == 3 )
{
midd = getMedian ( * s . begin () , * ++ s . begin () , * ++ ++ s . begin () );
int in;
for ( auto x : s )
{
if ( x != nxt [0] && x != fuck ) in = x;
}
if ( midd == nxt [0] )
{
ans [4] = in;
ans [5] = nxt [0];
ans [6] = fuck;
}
if ( midd == fuck )
{
ans [4] = nxt [0];
ans [5] = fuck;
ans [6] = in;
}
if ( midd == in )
{
ans [4] = nxt [0];
ans [5] = in;
ans [6] = fuck;
}
}
else
{
midd = getMedian ( * s . begin () , * ++ s . begin () , l );
int in;
for ( auto x : s )
{
if ( x != midd ) in = x;
}
ans [5] = midd;
ans [6] = in;
}
}
int W[] = { ans [1] , ans [2] , ans [3] , ans [4] , ans [5] , ans [6] };
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |