# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
222917 | DodgeBallMan | Scales (IOI15_scales) | C++14 | 5 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.
#include <bits/stdc++.h>
#include "scales.h"
#define pii pair<int, int>
#define x first
#define y second
using namespace std;
int ret[10], ans[10], coin[10];
vector<pii> all;
/*void answer( int a[] ) {
printf("ANS : ");
for( int i = 0 ; i < 6 ; i++ ) printf("%d ",a[i]);
printf("\n");
}
int getLightest( int a, int b, int c ) {
int p[3];
for( int i = 0 ; i < 6 ; i++ ) {
if( coin[i] == a ) p[0] = i;
else if( coin[i] == b ) p[1] = i;
else if( coin[i] == c ) p[2] = i;
}
sort( p, p+3 );
return coin[p[0]];
}
int getMedian( int a, int b, int c ) {
int p[3];
for( int i = 0 ; i < 6 ; i++ ) {
//printf("%d ",coin[i]);
if( coin[i] == a ) p[0] = i;
else if( coin[i] == b ) p[1] = i;
else if( coin[i] == c ) p[2] = i;
}
//printf("\n");
sort( p, p+3 );
//printf("%d %d %d %d %d %d\n",a,b,c,p[0],p[1],p[2]);
return coin[p[1]];
}
int getNextLightest( int a, int b, int c, int d ) {
int p[4], x, wow;
for( int i = 0 ; i < 6 ; i++ ) {
if( coin[i] == a ) p[0] = i;
else if( coin[i] == b ) p[1] = i;
else if( coin[i] == c ) p[2] = i;
else if( coin[i] == d ) p[3] = i, x = i;
}
sort( p, p+4 );
for( int i = 0 ; i < 4 ; i++ ) if( p[i] == x ) wow = i;
return coin[p[(wow+1)%4]];
}*/
void solve( int now ) {
int temp = getNextLightest( ans[0], ans[1], ans[2], ans[now] );
if( temp == ans[0] ) {
int temp2 = getLightest( ans[0], ans[1], ans[now] );
if( temp2 == ans[now] ) all.emplace_back( -1, now );
else all.emplace_back( 2, now );
}
else if( temp == ans[1] ) all.emplace_back( 0, now );
else all.emplace_back( 1, now );
}
void orderCoins() {
//for( int i = 0 ; i < 6 ; i++ ) printf("%d ",coin[i]);
//printf("\n");
memset( ret, 0, sizeof ret ), memset( ans, 0, sizeof ans ), all.clear();
ans[0] = getLightest( 1, 2, 3 );
ans[1] = getMedian( 1, 2, 3 );
ans[2] = 6 - ans[0] - ans[1];
ans[3] = getLightest( 4, 5, 6 );
ans[4] = getMedian( 4, 5, 6 );
ans[5] = 15 - ans[3] - ans[4];
//printf("ANS:");
//for( int i = 0 ; i < 6 ; i++ ) printf("%d ", ans[i]);
//printf("\n");
solve( 3 ), solve( 4 ), solve( 5 );
all.emplace_back( 0, 0 ), all.emplace_back( 1, 1 ), all.emplace_back( 2, 2 );
sort( all.begin(), all.end() );
for( int i = 0 ; i < 6 ; i++ ) ret[i] = ans[all[i].y];
answer( ret );
}
void init( int t ) {
}
/*int main()
{
int n;
scanf("%d",&n);
init( n );
}*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |