제출 #766928

#제출 시각아이디문제언어결과실행 시간메모리
766928turtlemode콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include "combo.h" #include <set> #include <list> #include <iostream> using namespace std; std::string guess_sequence(int N) { if (N == 0){ return ""; } std::string S = ""; if (press("AB")){ if (press("A")){ S += "A"; } else{ S += "B"; } } else { if (press("X")){ S += "X"; } else{ S += "Y"; } } if (N == 1){ return S; } set<string> all_chars {"A", "B", "X", "Y"}; all_chars.erase(S); vector<string> legal_chars; set<string>::iterator k; for (k = all_chars.begin(); k != all_chars.end(); ++k) legal_chars.push_back(*k); //cout << "Current: " << S << endl; while (S.length() < N - 1){ // int coins = press(S + "B" + S + "XB" + S + "XX" + S + "XY"); int coins = press(S + legal_chars[0] + S + legal_chars[1] + legal_chars[0] + S + legal_chars[1] + legal_chars[1] + S + legal_chars[1] + legal_chars[2]); if (coins == S.length() + 1){ S += legal_chars[0]; } else if (coins == S.length() + 2){ S += legal_chars[1]; } else if (coins == S.length() + 0){ S += legal_chars[2]; } else { //cout << "Wuut" << endl; } //cout << "Current: " << S << endl; } if (press(S + legal_chars[0]) == S.length() + 1){ return S + legal_chars[0]; } if (press(S + legal_chars[1]) == S.length() + 1){ return S + legal_chars[1]; } else{ return S + legal_chars[2]; } //cout << "Wuuut2" << endl; return S; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:32:3: error: 'vector' was not declared in this scope
   32 |   vector<string> legal_chars;
      |   ^~~~~~
combo.cpp:5:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    4 | #include <iostream>
  +++ |+#include <vector>
    5 | using namespace std;
combo.cpp:32:16: error: expected primary-expression before '>' token
   32 |   vector<string> legal_chars;
      |                ^
combo.cpp:32:18: error: 'legal_chars' was not declared in this scope; did you mean 'all_chars'?
   32 |   vector<string> legal_chars;
      |                  ^~~~~~~~~~~
      |                  all_chars
combo.cpp:38:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |   while (S.length() < N - 1){
      |          ~~~~~~~~~~~^~~~~~~
combo.cpp:41:15: 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 (coins == S.length() + 1){
      |         ~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:44:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     else if (coins == S.length() + 2){
      |              ~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:47:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     else if (coins == S.length() + 0){
      |              ~~~~~~^~~~~~~~~~~~~~~~~