Submission #1171769

#TimeUsernameProblemLanguageResultExecution timeMemory
1171769h1440Combo (IOI18_combo)C++20
100 / 100
7 ms600 KiB
#include "combo.h"
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fore(i,a,b) for(lli i = (a), abcdxd = (b); i < abcdxd; i++)
#define f first
#define s second
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define ENDL '\n'
#define sz(s) lli((s).size())
#define pb push_back
using namespace std;
typedef long long lli;
// typedef long long LLI;
typedef pair<lli, lli> ii;
typedef vector<lli> vi;
typedef vector<ii> vii;
typedef long double ld;
#define deb(x) cout << #x << ": " << x << endl;
#define BIGLLI __int128

std::string guess_sequence(int N) {
  string p = "";
  string ch;
  {
    lli cc = press("AB");
    if (cc){
      cc = press("A");
      if (cc) p = "A", ch = "BXY";
      else p = "B", ch = "AXY";
    }
    else{
      cc = press("X");
      if (cc) p = "X", ch = "ABY";
      else p = "Y", ch = "ABX";
    }
  }
  if (N == 1) return p;
  fore(i,1,N-1){
    lli cc = press((p + ch[0] + ch[0]) + (p + ch[0] + ch[1]) + (p + ch[0] + ch[2]) + (p + ch[1]));
    if (cc == (sz(p) + 2)) p += ch[0];
    else if (cc == (sz(p) + 1)) p += ch[1];
    else p += ch[2];
  }
  {
    lli cc = press((p + "A") + (p + "B"));
    if (cc == (sz(p) + 1)){
      cc = press(p + "A");
      if (cc == (sz(p) + 1)) p += "A";
      else p += "B";
    }
    else{
      cc = press(p + "X");
      if (cc == (sz(p) + 1)) p += "X";
      else p += "Y";
    }
  }
  return p;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...