| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 1285315 | ghammazhassan | Combo (IOI18_combo) | C++20 | 0 ms | 0 KiB | 
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <set>
#include <deque>
#include "combo.h"
using namespace std;
namespace {
constexpr int MAX_N = 2000;
constexpr int MAX_NUM_MOVES = 8000;
int N;
std::string S;
int num_moves;
void wrong_answer(const char *MSG) {
  printf("Wrong Answer: %s\n", MSG);
  exit(0);
}
}  // namespace
int press(std::string p) {
  if (++num_moves > MAX_NUM_MOVES) {
    wrong_answer("too many moves");
  }
  int len = p.length();
  if (len > 4 * N) {
    wrong_answer("invalid press");
  }
  for (int i = 0; i < len; ++i) {
    if (p[i] != 'A' && p[i] != 'B' && p[i] != 'X' && p[i] != 'Y') {
      wrong_answer("invalid press");
    }
  }
  int coins = 0;
  for (int i = 0, j = 0; i < len; ++i) {
    if (j < N && S[j] == p[i]) {
      ++j;
    } else if (S[0] == p[i]) {
      j = 1;
    } else {
      j = 0;
    }
    coins = std::max(coins, j);
  }
  return coins;
}
string guess_sequence(int n){
  string s;
  int x;
  for (int i=0;i<1;i++){
    s="AB";
    x=press(s);
    if (x){
      s="A";
      x=press(s);
      if (x){
        s="A";
        break;
      }
      s="B";
      break;
    }
    s="X";
    x=press(s);
    if (x){
      break;
    }
    s="Y";
  }
  string o;
  if (s=="A"){
    o="BXY";
  }
  if (s=="B"){
    o="AXY";
  }
  if (s=="X"){
    o="ABY";
  }
  if (s=="Y"){
    o="ABX";
  }
  string p;
  while (s.size()<n-1){
    p=s+o[0]+s+o[1]+o[0]+s+o[1]+o[1]+s+o[1]+o[2];
    x=press(p);
    if (x==s.size()+1){
      s+=o[0];
    }
    else if(x==s.size()+2){
      s+=o[1];
    }
    else{
      s+=o[2];
    }
  }
  p=s+o[0];
  x=press(p);
  if (x==s.size()+1){
    s+=o[0];
  }
  else{
    p=s+o[1];
    x=press(p);
    if (x==s.size()+1){
      s+=o[1];
    }
    else{
      s+=o[2];
    }
  }
  return s;
}
