Submission #870388

#TimeUsernameProblemLanguageResultExecution timeMemory
870388hgmhcCombo (IOI18_combo)C++17
100 / 100
13 ms1968 KiB
#include "combo.h"
#include <bits/stdc++.h>
#define siz(x) int((x).size())
using namespace std;

string guess_sequence(int N) {
  string p;
  string a="A", b="B", c="X", d="Y";
  
  // 2
  if (!press(a+b)) swap(a,c),swap(b,d);
  if (!press(a)) swap(a,b);
  if (N == 1) return a;
  p = a;
  
  // N-2
  for (;siz(p) < N-1;) {
    string q;
    q += p+b;
    q += p+c+b;
    q += p+c+c;
    q += p+c+d;

    int x = press(q);
    if (x == siz(p)) p += d;
    if (x == siz(p)+1) p += b;
    if (x == siz(p)+2) p += c;
  }
 
  // 2 
  if (press(p+b+p+c) == N-1) p += d;
  else if (press(p+b) == N-1) p += c;
  else p += b;
  
  return p;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...