Submission #615285

#TimeUsernameProblemLanguageResultExecution timeMemory
615285AriaHCombo (IOI18_combo)C++17
30 / 100
47 ms452 KiB
#include "combo.h"
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

#define F first
#define S second
#define all(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define Mp make_pair
#define endl "\n"
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 1e6 + 10;
const int LOG = 20;
const ll mod = 1e9 + 7;
const ll inf = 8e18;

string A[4] = {"A", "B", "X", "Y"};

vector < string > vec;

string guess_sequence(int n)
{
  mt19937 rng(58);
  string ans;
  shuffle(A, A + 4, rng);
  for(int j = 0; j < 3; j ++)
  {
    if(press(A[j]))
    {
      ans += A[j];
      break;
    }
  }
  if(ans == "") ans += A[3];
  for(int j = 0; j < 4; j ++)
  {
    if(ans == A[j]) continue;
    vec.push_back(A[j]);
  }
  int last = -1;
  for(int i = 1; i < n; i ++)
  {
    vector < int > opt;
    for(int j = 0; j < 3; j ++)
    {
      if(j == last) continue;
      opt.push_back(j);
    }
    for(int k = 0; k < SZ(opt) - 1; k ++)
    {
      int j = opt[k];
      int now = press(ans + vec[j] + vec[j]);
      if(now == i)
      {
        continue;
      }
      if(now == i + 1)
      {
        last = j;
        ans += vec[j];
        break;
      }
      if(now == i + 2)
      {
        ans += vec[j] + vec[j];
        i ++;
        last = -1;
        break;
      }
    }
    if(SZ(ans) == i)
    {
      ans += vec[opt.back()];
      last = -1;
    }
  }
  return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...