제출 #1359013

#제출 시각아이디문제언어결과실행 시간메모리
1359013avahw콤보 (IOI18_combo)C++20
컴파일 에러
0 ms0 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

std::string guess_sequence(int N) {
  std::string s = "";
  string ref = "ABXY";
  int n = N;
  // brute force first char
  for(int i = 0; i < ref.size(); i++){
    int coin = press(s + ref[i]);
    if(coin == 1){ s += ref[i];
    break; }
  }
  if(s.size() == 0) s += 'Y';
  // only need to guess three other chars
  string p = "";
  for(auto e : ref) if(e != s[0]) p += e;
  for(int i = 1; i < n - 1; i++){
    string guess = 
    s + p[0] + 
    s + p[1] + p[0] + 
    s + p[1] + p[1] + 
    s + p[1] + p[2];
    int coins = press(guess);
    int gain = coins - i;
    if(gain == 0){
      s += p[2];
    }
    if(gain == 1){
      s += p[0];
    }
    if(gain == 2){
      s += p[1]
    }
  }
  for(int i = 0; i < p.size(); i++){
    int coin = press(s + p[i]);
    if(coin == n){ s += p[i];
    break; }
  }
  return s;
}

컴파일 시 표준 에러 (stderr) 메시지

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:34:16: error: expected ';' before '}' token
   34 |       s += p[1]
      |                ^
      |                ;
   35 |     }
      |     ~