# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
973046 | PenguinsAreCute | Scales (IOI15_scales) | C++17 | 1 ms | 604 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.
// as a wise observer once said, "informatics students when the task is to be elegant"
// that one unemployed friend on a tuesday trying to solve this in 6 queries
// step 1: query 0,1,2. let 0 be median.
// step 2: query 3,4,5. let 3 be greatest.
// step 3: query nextlightest 0,4,5,1.
// If its 5 swap 4,5. So its 0 (26 cases) or 4 (27 cases)
// case a: its 0
// step 4a: query nextlight among 3,4,5,1
// case ai: we get 3
// step 5ai: query 0,4,5 for smallest
// If we get 0, either 140523 or 140532 is weight
// If we get 4, the weights are 324501 325401 425301
// case aii: we get 4 after step 4a
// step 5aii: median 234
// if median 2, its 103524 104523 214530
// if median 3, its 105423 215430 435201
// if median 4, its 102534 150423 213540
// case b of step 3: nextlightest 0451 is 4
// step 4b: query 1,2,4 for smallest
// 5bi: 1 smallest, then query 015 for median
// If 0 203514 204513 205413
// If 1 314520 315420 415320
// If 5 304512 305412 405312
// 5bii (2 smallest): query 045 for greatest
// If 0 340512 350412 450312
// if 4 130542 230541 231540
// If 5 120534 240513 250413
// 5biii (4 smallest): query 013 for median
// if 0 451302 452301 453201
// if 1 241503 341502 342501
// if 3 251403 351402 352401
#include "scales.h"
#include <bits/stdc++.h>
using namespace std;
void init(int T) {}
vector<int> findOrder() {
int W[] = {1, 2, 3, 4, 5, 6};
swap(W[getMedian(1,2,3)-1],W[0]);
swap(W[getHeaviest(4,5,6)-1],W[3]);
int meow = getNextLightest(W[0],W[4],W[5],W[1]);
if(meow==W[0]) {
meow = getNextLightest(W[3],W[4],W[5],W[1]);
if(meow==W[3]) {
meow = getLightest(W[0],W[4],W[5]);
if(meow==W[0]) {
meow = getLightest(W[3],W[4],W[5]);
if(meow==W[4]) return {W[2],W[0],W[4],W[5],W[1],W[3]};
else return {W[2],W[0],W[5],W[4],W[1],W[3]};
} else if(meow==W[5]) swap(W[4],W[5]);
meow = getMedian(W[0],W[2],W[3]);
if(meow==W[0]) return {W[4],W[5],W[1],W[3],W[0],W[2]};
if(meow==W[2]) return {W[4],W[5],W[1],W[0],W[2],W[3]};
return {W[4],W[5],W[1],W[0],W[3],W[2]};
}
if(meow==W[5]) swap(W[4],W[5]);
meow = getMedian(W[2],W[3],W[4]);
if(meow==W[2]) {
meow = getMedian(W[1],W[2],W[5]);
if(meow==W[1]) return {W[5],W[1],W[0],W[4],W[2],W[3]};
if(meow==W[2]) return {W[1],W[0],W[4],W[2],W[5],W[3]};
return {W[1],W[0],W[4],W[5],W[2],W[3]};
}
if(meow==W[3]) {
meow = getMedian(W[1],W[3],W[5]);
if(meow==W[1]) return {W[5],W[1],W[0],W[4],W[3],W[2]};
if(meow==W[3]) return {W[4],W[5],W[3],W[1],W[0],W[2]};
return {W[1],W[0],W[4],W[5],W[3],W[2]};
}
meow = getMedian(W[1],W[3],W[5]);
if(meow==W[1]) return {W[5],W[1],W[0],W[2],W[4],W[3]};
if(meow==W[3]) return {W[2],W[0],W[4],W[5],W[3],W[1]};
if(meow==W[5]) return {W[1],W[0],W[2],W[4],W[5],W[3]};
}
if(meow==W[5]) swap(W[4],W[5]);
meow = getLightest(W[1],W[2],W[4]);
if(meow==W[1]) {
meow = getMedian(W[0],W[1],W[5]);
if(meow==W[0]) {
meow = getMedian(W[2],W[3],W[5]);
if(meow==W[2]) return {W[1],W[4],W[0],W[5],W[2],W[3]};
if(meow==W[3]) return {W[1],W[4],W[0],W[5],W[3],W[2]};
return {W[1],W[4],W[0],W[2],W[5],W[3]};
}
if(meow==W[1]) {
meow = getMedian(W[0],W[2],W[3]);
if(meow==W[0]) return {W[5],W[1],W[4],W[3],W[0],W[2]};
if(meow==W[2]) return {W[5],W[1],W[4],W[0],W[2],W[3]};
return {W[5],W[1],W[4],W[0],W[3],W[2]};
}
meow = getMedian(W[0],W[2],W[3]);
if(meow==W[0]) return {W[1],W[4],W[5],W[3],W[0],W[2]};
if(meow==W[2]) return {W[1],W[4],W[5],W[0],W[2],W[3]};
return {W[1],W[4],W[5],W[0],W[3],W[2]};
}
if(meow==W[2]) {
meow = getHeaviest(W[0],W[4],W[5]);
if(meow==W[0]) {
meow = getMedian(W[0],W[1],W[3]);
if(meow==W[0]) return {W[2],W[4],W[5],W[3],W[0],W[1]};
if(meow==W[1]) return {W[2],W[4],W[5],W[0],W[1],W[3]};
return {W[2],W[4],W[5],W[0],W[3],W[1]};
}
if(meow==W[4]) {
meow = getMedian(W[0],W[2],W[5]);
if(meow==W[0]) return {W[2],W[0],W[5],W[1],W[4],W[3]};
if(meow==W[2]) return {W[5],W[2],W[0],W[1],W[4],W[3]};
return {W[2],W[5],W[0],W[1],W[4],W[3]};
}
meow = getMedian(W[1],W[3],W[5]);
if(meow==W[1]) return {W[2],W[4],W[0],W[5],W[1],W[3]};
if(meow==W[3]) return {W[2],W[4],W[0],W[5],W[3],W[1]};
return {W[2],W[0],W[1],W[4],W[5],W[3]};
}
meow = getMedian(W[0],W[1],W[3]);
if(meow==W[0]) {
meow = getMedian(W[2],W[3],W[5]);
if(meow==W[2]) return {W[4],W[5],W[2],W[3],W[0],W[1]};
if(meow==W[3]) return {W[4],W[5],W[3],W[2],W[0],W[1]};
return {W[4],W[2],W[5],W[3],W[0],W[1]};
}
if(meow==W[1]) {
meow = getMedian(W[0],W[2],W[5]);
if(meow==W[0]) return {W[4],W[2],W[0],W[5],W[1],W[3]};
if(meow==W[2]) return {W[4],W[5],W[2],W[0],W[1],W[3]};
return {W[4],W[2],W[5],W[0],W[1],W[3]};
}
meow = getMedian(W[0],W[2],W[5]);
if(meow==W[0]) return {W[4],W[2],W[0],W[5],W[3],W[1]};
if(meow==W[2]) return {W[4],W[5],W[2],W[0],W[3],W[1]};
return {W[4],W[2],W[5],W[0],W[3],W[1]};
}
void orderCoins() {
vector<int> v = findOrder();
int arr[6]; for(int i=0;i<6;i++) arr[i]=v[i];
answer(arr);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |