제출 #1113562

#제출 시각아이디문제언어결과실행 시간메모리
1113562Zflop콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; #include "combo.h" string letter = "ABXY"; std::string guess_sequence(int N) { string ans; vector<char>actual; for (int i = 0; i < 4;++i) if (press(letter[i])) { starting += letter[i]; } else actual.push_back(letter[i]); while(ans.size() < N - 1) { string g = ans + actual[0] + actual[0] + ans + actual[0] + actual[1] + ans + actual[0] + actual[2] + ans + actual[1]; int ret = press(g); if (ret == ans.size()) ans += actual[2]; else if (ret == ans.size() + 1) ans += actual[1]; else ans += actual[0]; } string g = ans + actual[0]; if (press(g) == N) return g; g = ans + actual[1]; if (press(g) == N) return g; return ans + actual[2]; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:13:21: error: could not convert 'letter.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>'}
   13 |  if (press(letter[i])) {
      |                     ^
      |                     |
      |                     __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}
combo.cpp:14:3: error: 'starting' was not declared in this scope; did you mean 'static'?
   14 |   starting += letter[i];
      |   ^~~~~~~~
      |   static
combo.cpp:12:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   12 |   for (int i = 0; i < 4;++i)
      |   ^~~
combo.cpp:18:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   18 |  while(ans.size() < N - 1) {
      |  ^~~~~
combo.cpp:18:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |  while(ans.size() < N - 1) {
      |        ~~~~~~~~~~~^~~~~~~
combo.cpp:21:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |   if (ret == ans.size())
      |       ~~~~^~~~~~~~~~~~~
combo.cpp:23:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |   else if (ret == ans.size() + 1)
      |            ~~~~^~~~~~~~~~~~~~~~~