Submission #1328363

#TimeUsernameProblemLanguageResultExecution timeMemory
1328363hxluk.kaCombo (IOI18_combo)C++20
100 / 100
8 ms584 KiB
#include "combo.h"
#include <vector>
#define pb push_back
using namespace std;
const int nx=2000;
vector<char> ops={'A', 'B', 'X', 'Y'}, nops;

string guess_sequence(int N) {
  char st;
  if (press("AB")) {
    if (press("B")) st='B';
    else st='A';
  } else {
    if (press("X")) st='X';
    else st='Y';
  }
  string res="";
  res+=st;
  if (N==1) return res;
  for (int i=0; i<4; i++) if (ops[i]!=st) nops.pb(ops[i]);
  for (int i=1; i<N-1; i++) {
    string t=(res+nops[0])+(res+nops[1]+nops[0])+(res+nops[1]+nops[1])+(res+nops[1]+nops[2]);
    int s=press(t);
    if (s==res.size()) res+=nops[2];
    else if (s==res.size()+1) res+=nops[0];
    else res+=nops[1];
  }
  for (int i=0; i<2; i++) if (press(res+nops[i])==N) return res+nops[i];
  return res+nops[2];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...