Submission #761202

#TimeUsernameProblemLanguageResultExecution timeMemory
761202JANCARAPANCombo (IOI18_combo)C++17
5 / 100
1 ms256 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;  
#define ll long long
#define fi first
#define se second
#define sz(a) (long long) a.size()
#define endl '\n'
 
#define dbg(a) cerr << #a << " = " << a << endl;
#define print(a) for (auto x : a) cerr << x << " "; cerr << endl;
 
const long long INF = 1e18, MOD = 1e9+7; 
 
 
string guess_sequence(int n) {
  string s = "";
  vector<string> a = {"A", "B", "X", "Y"};
  
  int it = 0;
  if (press("AB")) {
    if (press("A")) it = 0;
    else it = 1;
  }
  else {
    if (press("X")) it = 2;
    else it = 3;
  }
  
  s += a[it];
  
  int x = (it + 1) % 4, y = (it + 2) % 4, z = (it + 3) % 4;
  
  for (int i = 1; i < n - 1; i++) {
    int ans = press(s+a[x]+a[y] + s+a[x]+a[z] + s+a[x]+a[x] + s+a[y]);
    if (ans == sz(s) + 2) {
      s += a[x];
    } 
    else if (ans == sz(s) + 1) {
      s += a[y];
    }
    else {
      s += a[z];
    }
  }
  
  if (press(s + a[x]) == sz(s) + 1) it = x;
  else if (press(s + a[y]) == sz(s) + 1) it = y;
  else it = z;
  
  s += a[it];
  
  return s;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...