Submission #1142228

#TimeUsernameProblemLanguageResultExecution timeMemory
1142228vyaductCombo (IOI18_combo)C++20
0 / 100
0 ms408 KiB
#include <bits/stdc++.h>
#include "combo.h"
#define DEBUG false
#define DBG(x) cout << #x << " = " << x << ";\n";
using namespace std;

string guess_sequence(int N) {
  // Guessing first letter
  set<string> S;
  S.insert("A");
  S.insert("B");
  S.insert("X");
  S.insert("Y");
  string trash = "AB";
  string p = "";
  int ans = press(trash);
  if (ans >= 1){
    trash = "A";
    ans = press(trash);
    if (ans == 1) p += "A";
    else p += "B";
  } else {
    trash = "X";
    ans = press(trash);
    if (ans == 1) p += "X";
    else p += "Y";
  }

  S.erase(p);
  // Remaining letters up to the (n-1)th
  int c=0;
  string B,X,Y;
  for (auto x: S){
    if (c == 0) B = x;
    if (c == 1) X = x;
    if (c == 2) Y = x;
    c++;
  }

  int cnt=1;
  for (int i=1;i<N-1;i++){
    string trash = (p + B) + (p + X + B) + (p + X + X) + (p + X + Y);
    DBG(trash)
    ans = press(trash);
    if (ans == cnt) p += Y;
    if (ans == cnt+1) p += B;
    if (ans == cnt+2) p += X;
    DBG(p)
    cnt++;
  }
  
  if (N > 1){
    // last letter
    ans = press(p + B);
    if (ans == N) p += B;
    else {
      ans = press(p + X);
      if (ans == N) p += X;
      else p += Y;
    }
  }
  return p;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...