Submission #1317673

#TimeUsernameProblemLanguageResultExecution timeMemory
1317673channkCombo (IOI18_combo)C++20
100 / 100
8 ms476 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

string guess_sequence(int N) {
  string ans;
  
  int r = press("AB");
  if(r==2) ans = "AB";
  else if(r==1) ans = (press("A") == 1) ? "A" : "B";
  else ans = (press("X")==1) ? "X" : "Y";
  if(ans.size()==N) return ans;

  vector<char> others;
  for(char c : {'A','B','X','Y'})
    if(c!=ans[0]) others.push_back(c);
  
  while(ans.size()+1 < N){
    string q = ans + others[0] + ans + others[1] + others[0] + ans + others[1] + others[1] + ans + others[1] + others[2];
    int len = ans.size();
    r = press(q);
    if (r == len) ans += others[2];
    else if (r == len + 1) ans += others[0];
    else ans += others[1];
  }
  
  if(press(ans+others[0]) == N) ans += others[0];
  else if(press(ans+others[1]) == N) ans += others[1];
  else ans += others[2];
  
  return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...