제출 #281712

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

using namespace std;

string del(string s, char ch) {
  string t;
  for (auto &x : s) {
    if (x != ch) {
      t += x;
    }
  }
  return t;
}


mt19937 rng((long long) (new char));

string guess_sequence(int n) {
  string sol;
  string posi = "ABXY";
  if (press(posi[0] + posi[1]) > 0) {
    if (press(posi[0])) {
      sol += posi[0];
    } else {
      sol += posi[1];
    }
  } else {
    if (press(posi[2])) {
      sol += posi[2];
    } else {
      sol += posi[3];
    }
  }
  posi = del(posi, sol[0]);
  while ((int) sol.size() < n) {
    bool found = 0;
    shuffle(posi.begin(), posi.end(), rng);
    for (int j = 0; j < 2; j++) {
      if (press(sol + posi[j]) == (int) sol.size() + 1) {
        found = 1;
        sol += posi[j];
        break;
      }
    }
    if (found == 0) {
      sol += posi[2];
    }
  }
  return sol;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:22:21: error: could not convert '(((int)posi.std::__cxx11::basic_string<char>::operator[](0)) + ((int)posi.std::__cxx11::basic_string<char>::operator[](1)))' from 'int' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   22 |   if (press(posi[0] + posi[1]) > 0) {
combo.cpp:23:22: error: could not convert 'posi.std::__cxx11::basic_string<char>::operator[](0)' from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   23 |     if (press(posi[0])) {
      |                      ^
      |                      |
      |                      __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}
combo.cpp:29:22: error: could not convert 'posi.std::__cxx11::basic_string<char>::operator[](2)' from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   29 |     if (press(posi[2])) {
      |                      ^
      |                      |
      |                      __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}