# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
256598 | oscarsierra12 | Scales (IOI15_scales) | C++14 | 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.
#include "scales.h"
#include <bits/stdc++.h>
using namespace std ;
void init(int T) {
/* ... */
}
void orderCoins() {
/* ... */
vector<int> coins, W ;
int x;
for ( int i = 1 ; i < 7 ; ++i ) coins.push_back(i) ;
for ( int i = 2 ; i < 6 ; i += 2 ) {
x = getLightest(coins[1], coins[i], coins[i+1]) ;
if (x == coins[i]) swap(coins[1], coins[i]) ;
if (x == coins[i+1]) swap(coins[1], coins[i+1]) ;
}
x = getHeaviest(coins[2], coins[3], coins[4]) ;
set<int> cual ;
for (int i = 2 ; i < 5 ; ++i) cual.insert(coins[i]) ;
for ( int i = 2 ; i < 5 ; ++i ) {
if (x != coins[i]) continue ;
swap(coins[i], coins[5]) ;
break ;
}
x = getNextLightest(coins[2], coins[3], coins[4], coins[1]) ;
for ( int i = 2 ; i < 5 ; ++i ) {
if (x != coins[i]) continue ;
swap(coins[i], coins[2]) ;
break ;
}
x = getMedian(coins[3], coins[4], coins[5]) ;
if (x == coins[5]) {
if (cual.count(coins[4])) swap(coins[3], coins[4]) ;
swap(coins[4], coins[5]) ;
}
else if (cual.count(x)) {
if(cual.count(coins[3])) swap(coins[3], coins[4]) ;
}
else if (cual.count(coins[4])) swap(coins[3],coins[4]) ;
x = getMedian(coins[0], coins[2], coins[4]) ;
if(x == coins[2]) {
x = getLightest(coins[0], coins[1], coins[2]) ;
W.push_back(coins[0]) ;
W.push_back(coins[1]) ;
if (x == coins[1]) swap(W[0], W[1]) ;
for ( int i = 2 ; i < 6 ; ++i ) W.push_back(coins[i]) ;
}
else if (x == coins[4]) {
x = getHeaviest(coins[0], coins[5], coins[4]) ;
for ( int i = 1 ; i < 5 ; ++i ) W.push_back(coins[i]) ;
W.push_back(coins[0]) ;
W.push_back(coins[5]) ;
if (x == coins[0]) swap(W[4], W[5]) ;
}
else {
x = getNextLightest(coins[2], coins[3], coins[4], coins[0]) ;
for ( int i = 1 ; i < 6 ; ++i ) {
if (x != coins[i]) {
W.push_back(coins[i]) ;
continue ;
}
W.push_back(coins[0]) ;
for ( int j = i ; j < 6 ; ++j) W.push_back(coins[j]) ;
break ;
}
}
int Wr[] = {W[0], W[1], W[2], W[3], W[4], W[5]};
answer(Wr);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |