제출 #933331

#제출 시각아이디문제언어결과실행 시간메모리
933331SulA콤보 (IOI18_combo)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int N) { string s; vector<char> a(4) = {'A','B','X','Y'}; int x = press("AB"); if (x == 2) s += "AB"; else if (x == 1) { s = (press("A") == 1 ? "A" : "B"); } else { s = (press("X") == 1 ? "X" : "Y"); } if (N == 1) return s; int first = find(a.begin(), a.end(), s[0]); erase(first, a.begin(), a.end()); for (int i = s.size(); i < n-1; i++) { x = press(s + a[0] + s + a[1] + a[0] + s + a[1] + a[1] + s + a[1] + a[2]); if (x == s.size()) s += a[2]; else if (x == s.size() + 1) s += a[1]; else s += a[2]; } x = press(s + a[0]); if (x > s.size()) return s + a[0]; else if (press(s + a[1]) > s.size()) return s + a[1]; return s + a[2]; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:7:23: error: expected ',' or ';' before '=' token
    7 |     vector<char> a(4) = {'A','B','X','Y'};
      |                       ^
combo.cpp:18:21: error: cannot convert '__gnu_cxx::__normal_iterator<char*, std::vector<char> >' to 'int' in initialization
   18 |     int first = find(a.begin(), a.end(), s[0]);
      |                 ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
      |                     |
      |                     __gnu_cxx::__normal_iterator<char*, std::vector<char> >
combo.cpp:19:5: error: 'erase' was not declared in this scope
   19 |     erase(first, a.begin(), a.end());
      |     ^~~~~
combo.cpp:20:32: error: 'n' was not declared in this scope
   20 |     for (int i = s.size(); i < n-1; i++) {
      |                                ^
combo.cpp:22:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         if (x == s.size()) s += a[2];
      |             ~~^~~~~~~~~~~
combo.cpp:23:20: 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 (x == s.size() + 1) s += a[1];
      |                  ~~^~~~~~~~~~~~~~~
combo.cpp:28:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     if (x > s.size()) return s + a[0];
      |         ~~^~~~~~~~~~
combo.cpp:29:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     else if (press(s + a[1]) > s.size()) return s + a[1];
      |              ~~~~~~~~~~~~~~~~^~~~~~~~~~