# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
383678 | wlh_code | 콤보 (IOI18_combo) | C++17 | 컴파일 에러 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "combo.h"
using namespace std;
string guess_sequence (int N) {
string keys = "ABXY"; string s;
for (int i = 0; i < 4; ++i) {
if (press(keys[i])) {
s += keys[i];
keys.erase(keys.begin() + i, 1);
break;
}
}
for (int i = 1; i < N; ++i) {
for (int j = 0; j < 3; ++j) {
if (press(keys[j]) > i) {
s += keys[j];
break;
}
}
}
return s;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)': combo.cpp:6:20: error: could not convert 'keys.std::__cxx11::basic_string<char>::operator[](((std::__cxx11::basic_string<char>::size_type)i))' from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'std::string' {aka 'std::__cxx11::basic_string<char>'} 6 | if (press(keys[i])) { | ^ | | | __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char} combo.cpp:8:34: error: no matching function for call to 'std::__cxx11::basic_string<char>::erase(__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >, int)' 8 | keys.erase(keys.begin() + i, 1); | ^ In file included from /usr/include/c++/10/string:55, from combo.h:3, from combo.cpp:1: /usr/include/c++/10/bits/basic_string.h:1806:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::erase(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]' 1806 | erase(size_type __pos = 0, size_type __n = npos) | ^~~~~ /usr/include/c++/10/bits/basic_string.h:1806:23: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >' to 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} 1806 | erase(size_type __pos = 0, size_type __n = npos) | ~~~~~~~~~~^~~~~~~~~ /usr/include/c++/10/bits/basic_string.h:1825:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::erase(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::__const_iterator) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator = std::__cxx11::basic_string<char>::iterator; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::__const_iterator = std::__cxx11::basic_string<char>::const_iterator]' 1825 | erase(__const_iterator __position) | ^~~~~ /usr/include/c++/10/bits/basic_string.h:1825:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/10/bits/basic_string.h:1844:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::erase(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::__const_iterator, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::__const_iterator) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator = std::__cxx11::basic_string<char>::iterator; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::__const_iterator = std::__cxx11::basic_string<char>::const_iterator]' 1844 | erase(__const_iterator __first, __const_iterator __last) | ^~~~~ /usr/include/c++/10/bits/basic_string.h:1844:56: note: no known conversion for argument 2 from 'int' to 'std::__cxx11::basic_string<char>::__const_iterator' {aka 'std::__cxx11::basic_string<char>::const_iterator'} 1844 | erase(__const_iterator __first, __const_iterator __last) | ~~~~~~~~~~~~~~~~~^~~~~~ combo.cpp:14:21: error: could not convert 'keys.std::__cxx11::basic_string<char>::operator[](((std::__cxx11::basic_string<char>::size_type)j))' from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'std::string' {aka 'std::__cxx11::basic_string<char>'} 14 | if (press(keys[j]) > i) { | ^ | | | __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}