제출 #849562

#제출 시각아이디문제언어결과실행 시간메모리
849562chilengaming콤보 (IOI18_combo)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #include "combo.h" using namespace std; char first_char () { int tmp = press("AB"); if(tmp == 2) { return 'A'; } else if(tmp == 1) { if(press("A") == 1) { return 'A'; } else { return 'B'; } } else { if(press("X") == 1) { return 'X'; } else { return 'Y'; } } } char last_char(string s, string tmp, int n) { if(press(s + tmp[0]) == n) return tmp[0]; else if(press(s + tmp[1]) == n) return tmp[1]; else return tmp[2]; } string guess_sequence(int N) { string s = ""; char c_first = first_char(); string tmp; if(c_first == 'A') tmp = "BXY"; else if(c_first == 'B') tmp = "AXY"; else if(c_first == 'X') tmp = "ABY"; else tmp = "ABX"; while(s.size() < N - 1) { int t = press(s + tmp[0] + tmp[0] + s + tmp[0] + tmp[1] + s + tmp[0] + tmp[2] + s + tmp[1]); if(t == s.size() + 2) { s = s + tmp[0]; } else if(t == s.size() + 1) { s = s + tmp[1]; } else { s = s + tmp[2]; } } char c_last = last_char(s, tmp, N); string t1 = "", t2 = ""; t1 += first_char; t2 += last_char; return t1 + s + t2; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:39:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |     while(s.size() < N - 1) {
      |           ~~~~~~~~~^~~~~~~
combo.cpp:41:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         if(t == s.size() + 2) {
      |            ~~^~~~~~~~~~~~~~~
combo.cpp:44:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         if(t == s.size() + 1) {
      |            ~~^~~~~~~~~~~~~~~
combo.cpp:52:8: error: no match for 'operator+=' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'char()')
   52 |     t1 += first_char;
      |     ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from combo.cpp:1:
/usr/include/c++/10/bits/basic_string.h:1157:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' (near match)
 1157 |       operator+=(_CharT __c)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1157:7: note:   conversion of argument 1 would be ill-formed:
combo.cpp:52:11: error: invalid conversion from 'char (*)()' to 'char' [-fpermissive]
   52 |     t1 += first_char;
      |           ^~~~~~~~~~
      |           |
      |           char (*)()
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from combo.cpp:1:
/usr/include/c++/10/bits/basic_string.h:1139:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1139 |       operator+=(const basic_string& __str)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1139:38: note:   no known conversion for argument 1 from 'char()' to 'const std::__cxx11::basic_string<char>&'
 1139 |       operator+=(const basic_string& __str)
      |                  ~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:1148:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1148 |       operator+=(const _CharT* __s)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1148:32: note:   no known conversion for argument 1 from 'char()' to 'const char*'
 1148 |       operator+=(const _CharT* __s)
      |                  ~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/basic_string.h:1170:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(std::initializer_list<_Tp>) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1170 |       operator+=(initializer_list<_CharT> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1170:43: note:   no known conversion for argument 1 from 'char()' to 'std::initializer_list<char>'
 1170 |       operator+=(initializer_list<_CharT> __l)
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/basic_string.h:1182:2: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const _Tp&) [with _Tp = _Tp; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1182 |  operator+=(const _Tp& __svt)
      |  ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1182:2: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from combo.cpp:1:
/usr/include/c++/10/type_traits: In substitution of 'template<bool _Cond, class _Tp> using enable_if_t = typename std::enable_if::type [with bool _Cond = false; _Tp = std::__cxx11::basic_string<char>&]':
/usr/include/c++/10/bits/basic_string.h:117:8:   required by substitution of 'template<class _CharT, class _Traits, class _Alloc> template<class _Tp, class _Res> using _If_sv = std::enable_if_t<std::__and_<std::is_convertible<const _Tp&, std::basic_string_view<_CharT, _Traits> >, std::__not_<std::is_convertible<const _Tp*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>*> >, std::__not_<std::is_convertible<const _Tp&, const _CharT*> > >::value, _Res> [with _Tp = char(); _Res = std::__cxx11::basic_string<char>&; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
/usr/include/c++/10/bits/basic_string.h:1182:2:   required by substitution of 'template<class _Tp> std::__cxx11::basic_string<char>::_If_sv<_Tp, std::__cxx11::basic_string<char>&> std::__cxx11::basic_string<char>::operator+=<_Tp>(const _Tp&) [with _Tp = char()]'
combo.cpp:52:11:   required from here
/usr/include/c++/10/type_traits:2554:11: error: no type named 'type' in 'struct std::enable_if<false, std::__cxx11::basic_string<char>&>'
 2554 |     using enable_if_t = typename enable_if<_Cond, _Tp>::type;
      |           ^~~~~~~~~~~
combo.cpp:53:8: error: no match for 'operator+=' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'char(std::string, std::string, int)' {aka 'char(std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char>, int)'})
   53 |     t2 += last_char;
      |     ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from combo.cpp:1:
/usr/include/c++/10/bits/basic_string.h:1157:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' (near match)
 1157 |       operator+=(_CharT __c)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1157:7: note:   conversion of argument 1 would be ill-formed:
combo.cpp:53:11: error: invalid conversion from 'char (*)(std::string, std::string, int)' {aka 'char (*)(std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char>, int)'} to 'char' [-fpermissive]
   53 |     t2 += last_char;
      |           ^~~~~~~~~
      |           |
      |           char (*)(std::string, std::string, int) {aka char (*)(std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char>, int)}
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from combo.cpp:1:
/usr/include/c++/10/bits/basic_string.h:1139:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1139 |       operator+=(const basic_string& __str)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1139:38: note:   no known conversion for argument 1 from 'char(std::string, std::string, int)' {aka 'char(std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char>, int)'} to 'const std::__cxx11::basic_string<char>&'
 1139 |       operator+=(const basic_string& __str)
      |                  ~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:1148:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1148 |       operator+=(const _CharT* __s)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1148:32: note:   no known conversion for argument 1 from 'char(std::string, std::string, int)' {aka 'char(std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char>, int)'} to 'const char*'
 1148 |       operator+=(const _CharT* __s)
      |                  ~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/basic_string.h:1170:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(std::initializer_list<_Tp>) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1170 |       operator+=(initializer_list<_CharT> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1170:43: note:   no known conversion for argument 1 from 'char(std::string, std::string, int)' {aka 'char(std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char>, int)'} to 'std::initializer_list<char>'
 1170 |       operator+=(initializer_list<_CharT> __l)
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/basic_string.h:1182:2: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const _Tp&) [with _Tp = _Tp; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1182 |  operator+=(const _Tp& __svt)
      |  ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1182:2: note:   template argument deduction/substitution failed:
combo.cpp:50:10: warning: unused variable 'c_last' [-Wunused-variable]
   50 |     char c_last = last_char(s, tmp, N);
      |          ^~~~~~