Submission #1265736

#TimeUsernameProblemLanguageResultExecution timeMemory
1265736julia_08Scales (IOI15_scales)C++20
55.56 / 100
0 ms328 KiB
#include <bits/stdc++.h>
#include "scales.h"

using namespace std;

void init(int T){

}

void add(vector<int> &ans, int nxt, int x){

  if(nxt == ans[0]){
    ans.push_back(x);
    return;
  }

  vector<int> new_ans;

  for(auto i : ans){
    if(i == nxt) new_ans.push_back(x);
    new_ans.push_back(i);
  }

  ans = new_ans;

}

void orderCoins(){

  // 8 queries

  int A[3], B[3];

  A[0] = getLightest(1, 2, 3);
  A[1] = getMedian(1, 2, 3);

  A[2] = 6 - A[0] - A[1];

  B[0] = getLightest(4, 5, 6);
  B[1] = getMedian(4, 5, 6);

  B[2] = 15 - B[0] - B[1];

  // A[0] < B[0] ?

  vector<int> ans;

  if(getLightest(A[0], B[0], A[1]) == B[0]) swap(A, B);

  ans.push_back(A[0]);
  ans.push_back(A[1]);
  ans.push_back(A[2]);

  add(ans, getNextLightest(A[0], A[1], A[2], B[0]), B[0]);
  add(ans, getNextLightest(A[0], A[1], A[2], B[1]), B[1]);
  add(ans, getNextLightest(A[0], A[1], A[2], B[2]), B[2]);

  int W[6];

  for(int i=0; i<6; i++) W[i] = ans[i];

  answer(W);

}
#Verdict Execution timeMemoryGrader output
Fetching results...