제출 #1020956

#제출 시각아이디문제언어결과실행 시간메모리
1020956AishaCombo (IOI18_combo)C++17
30 / 100
40 ms980 KiB
#include "combo.h"

#include <bits/stdc++.h>

using namespace std;

std::string guess_sequence(int N) {
  string s = "";

  string A = "ABXY";

  for (int i = 0; i < 3; i++) {
    string k = "";
    k += A[i];
    if (press(k) == 1) {
      s = s + A[i];
      break;
    }
  }

  if (s == "") {
    s = "Y";
  }

  string a = "";
  for (char c : A) {
    if (s[0] != c) a = a + c;
  }
  
  bool ok = false;

  int coins = 1, maxcoins = 1;
  while (maxcoins < N){
    coins = maxcoins;

    for (int i = 0; i < 2; i++) {
      if (!ok) {
        if (press(s + a[i]) > coins) {
          maxcoins ++;
          s = s + a[i];
          ok = true;
        } 
      }
    }

    if (!ok) {
      s = s + a[2];
      maxcoins ++;
    }
    
    ok = false;
  }

  return s;
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...