Submission #1297792

#TimeUsernameProblemLanguageResultExecution timeMemory
1297792martin_011Combo (IOI18_combo)C++20
100 / 100
8 ms472 KiB
#include "combo.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define str string

str guess_sequence(int n) {
  str res = "";
  vector<char> c(4);
  c = {'A', 'B', 'X', 'Y'};
  str p = "";
  p.push_back(c[0]);
  p.push_back(c[1]);
  ll r = press(p);
  if (r==0) {
    char a1, a2;
    a1 = c[2];
    a2 = c[3];
    c[2] = c[0];
    c[3] = c[1];
    c[0]=a1;
    c[1]=a2;
  }
  p = "";
  p.push_back(c[0]);
  r = press(p);
  if (r==0) {
    char aux = c[1];
    c[1] = c[0];
    c[0]=aux;
  }
  res.push_back(c[0]);
  if (n==1) return res;
  ll t = 1;
  for (int i=1; i<(n-1); i++) {
    p = "";
    p += res;
    p.push_back(c[3]);
    p.push_back(c[1]);
    //AA
    p += res;
    p.push_back(c[3]);
    p.push_back(c[2]);
    //AB
    p += res;
    p.push_back(c[3]);
    p.push_back(c[3]);
    //AY
    p += res;
    p.push_back(c[2]);
    r = press(p);
    r-=t;
    r++;
    res.push_back(c[r]);
    t++;
  }
  p = res;
  p.push_back(c[1]);
  r = press(p);
  if (r==n) {
    res.push_back(c[1]);
  } else {
    p = res;
    p.push_back(c[2]);
    r = press(p);
    if (r==n) {
      res.push_back(c[2]);
    } else {
      res.push_back(c[3]);
    }
  }
  return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...