제출 #485497

#제출 시각아이디문제언어결과실행 시간메모리
485497JooCombo (IOI18_combo)C++17
컴파일 에러
0 ms0 KiB
#include "combo.h" using namespace std; /*#include <bits/stdc++.h> using namespace std; int press(string p){ cout << p << "\n"; int x; cin >> x; return x; }*/ string guess_sequence(int N){ string str; vector<char> a = {'A', 'B', 'X', 'Y'}; if(press("AB") == 0){ ///either x or y if(press("X") == 1){ str += 'X'; a.erase(a.begin()+2); }else{ str += 'Y'; a.erase(a.begin()+3); } }else{ ///either a or b if(press("A") == 1){ str += 'A'; a.erase(a.begin()); }else{ str += 'B'; a.erase(a.begin()+1); } } for(int i = 2; i < N; i++){ string tmp = str + a[1] + str + a[2] + a[0] + str + a[2] + a[1] + str + a[2] + a[2]; int res = press(tmp); if(res == str.size()){ ///got nothing new str += a[0]; }else if(res == str.size()+1){ str += a[1]; }else{ str += a[2]; } } if(press(str+a[0]) == N){ str += a[0]; }else if(press(str+a[1]) == N){ str += a[1]; }else{ str += a[2]; } return str; } /* int main(void){ cout << guess_sequence(5) << "\n"; return 0; } */

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:13:5: error: 'vector' was not declared in this scope
   13 |     vector<char> a = {'A', 'B', 'X', 'Y'};
      |     ^~~~~~
combo.cpp:2:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    1 | #include "combo.h"
  +++ |+#include <vector>
    2 | using namespace std;
combo.cpp:13:12: error: expected primary-expression before 'char'
   13 |     vector<char> a = {'A', 'B', 'X', 'Y'};
      |            ^~~~
combo.cpp:18:13: error: 'a' was not declared in this scope
   18 |             a.erase(a.begin()+2);
      |             ^
combo.cpp:21:13: error: 'a' was not declared in this scope
   21 |             a.erase(a.begin()+3);
      |             ^
combo.cpp:26:13: error: 'a' was not declared in this scope
   26 |             a.erase(a.begin());
      |             ^
combo.cpp:29:13: error: 'a' was not declared in this scope
   29 |             a.erase(a.begin()+1);
      |             ^
combo.cpp:34:28: error: 'a' was not declared in this scope
   34 |         string tmp = str + a[1] + str + a[2] + a[0] + str + a[2] + a[1] + str + a[2] + a[2];
      |                            ^
combo.cpp:37:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         if(res == str.size()){ ///got nothing new
      |            ~~~~^~~~~~~~~~~~~
combo.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         }else if(res == str.size()+1){
      |                  ~~~~^~~~~~~~~~~~~~~
combo.cpp:46:18: error: 'a' was not declared in this scope
   46 |     if(press(str+a[0]) == N){
      |                  ^