제출 #379842

#제출 시각아이디문제언어결과실행 시간메모리
379842SuhaibSawalha1콤보 (IOI18_combo)C++14
0 / 100
1 ms200 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

vector<char> ca {'A', 'B', 'X', 'Y'}, cand;

string guess_sequence (int n) {
  string ans;
  for (int i = 0; i < 4; ++i) {
    if (i == 3) {
      ans = ca[i];
      ca.erase(ca.begin() + i);
      cand = ca;
      break;
    }
    int x = press(ans + ca[i] + (i ? 'A' : 'B'));
    if (x) {
      ans = ca[i];
      ca.erase(ca.begin() + i);
      if (x == 1) {
        cand = ca;
        cand.erase(find(cand.begin(), cand.end(), i ? 'A' : 'B'));
      }
      else {
        cand = {i ? 'A' : 'B'};
      }
      break;
    }
  }
  if (n == 1) {
    return ans;
  }
  for (int i = 1; i < n - 1; ++i) {
    for (char c : cand) {
      int x = press(ans + c + (c == ca[0] ? ca[1] : c)) - i;
      if (x) {
        ans += c;
        if (x == 1) {
          cand = ca;
          cand.erase(find(cand.begin(), cand.end(), (c == ca[0] ? ca[1] : c)));
        }
        else {
          cand = {c == ca[0] ? ca[1] : c};
        }
        break;
      }
    }
  }
  return ans + (press(ans + cand[0]) == n ? cand[0] : cand[1]);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...