제출 #685821

#제출 시각아이디문제언어결과실행 시간메모리
685821grossly_overconfident콤보 (IOI18_combo)C++17
컴파일 에러
0 ms0 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string f; vector<char> letter; if (press("AB") != 0) { if (press("A") == 1) { f = "A"; letter = { 'B', 'X', 'Y' }; } else { f = "B"; letter = { 'A', 'X', 'Y' }; } } else { if (press("X") == 1) { f = "X"; letter = { 'B', 'A', 'Y' }; } else { f = "Y"; letter = { 'B', 'X', 'A' }; } } int l = 1; string result = f; while (l < N) { string testcase; testcase = result + letter[0] + letter[1] + result + letter[1] + letter[0]; int outcome = press(testcase); if (outcome == l) { result += letter[2]; l += 1; } else if (outcome == l + 2) { testcase = result; testcase += letter[0] + letter[1]; if (press(testcase) == l) { result += letter[1] + letter[0]; } else { result += letter[0] + letter[1]; } l += 2; } else { testcase = result; testcase += letter[0] + letter[2]; if (press(testcase) == l) { result += letter[1] + letter[2]; } else { result += letter[0] + letter[2]; } l += 2; } } if (l == N) { return result; } if (press(letter[0]) > l) { result += letter[0]; return result; } if (press(letter[1]) > l) { result += letter[1]; return result; } result += letter[2]; return result; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:63:24: error: could not convert 'letter.std::vector<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>'}
   63 |     if (press(letter[0]) > l) {
      |                        ^
      |                        |
      |                        __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}
combo.cpp:67:24: error: could not convert 'letter.std::vector<char>::operator[](1)' from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   67 |     if (press(letter[1]) > l) {
      |                        ^
      |                        |
      |                        __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}