Submission #1301696

#TimeUsernameProblemLanguageResultExecution timeMemory
1301696jkcdonnyCombo (IOI18_combo)C++20
100 / 100
11 ms504 KiB
#include "combo.h"
#include "bits/stdc++.h"

using namespace std;

#define FOR(i,j,k) for(int i=j;i<k;i++)

const char L[] = "ABXY";

int twoN (const string& s) {
  int c = press(s+L[0]+s+L[1]);
  int k = 2 * (c <= s.length());
  c = press(s+L[k]);
  k += (c <= s.length());
  return k;
}

string guess_sequence(int N) {
  string s;
  int a[4];
  FOR(i,0,4) { a[i] = i; }
  
  int k = twoN(s);
  s += L[k];
  swap(a[k], a[3]);

  FOR(i,0,N-2) {
    string z;
    FOR(j,0,3) {
      z += s + L[a[0]] + L[a[j]];
    }
    z += s + L[a[1]];
    int cyc = press(z);
    if (cyc == i+2) {
      s += L[a[1]];
    } else if (cyc == i+3) {
      s += L[a[0]];
    } else {
      s += L[a[2]];
    }
  }


  if (N>1) {
    int k = twoN(s);
    s += L[k];
  }
  

  return s;
}


/* 2N bound
FOR(i,0,N) {
    int c = press(s+L[0]+s+L[1]);
    int k = 2 * (c <= i);
    c = press(s+L[k]);
    k += (c <= i);
    s += L[k];
  }
    */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...