제출 #362151

#제출 시각아이디문제언어결과실행 시간메모리
362151penguinhacker콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include <string> #include <vector> #include <assert.h> using namespace std; string guess_sequence(int n) { string ans; if (press("AB") > 0) { if (press("A")) ans = "A"; else ans = "B"; } else { if (press("X")) ans = "X"; else ans = "Y"; } assert((int)ans.size() == 1); vector<char> v; if (ans != "A") v.push_back('A'); if (ans != "B") v.push_back('B'); if (ans != "X") v.push_back('X'); if (ans != "Y") v.push_back('Y'); assert(v.size() == 3); for (int i = 1; i < n - 1; ++i) { string s = ans + v[0] + v[0] + ans + v[0] + v[1] + ans + v[0] + v[2] + ans + v[1]; assert((int)s.size() <= 4 * n); int x = press(s); if (x == i) ans += v[2]; else if (x == i + 1) ans += v[1]; else if (x == i + 2) ans += v[0]; else assert(0); } assert((int)ans.size() == n - 1); if (press(ans + v[0]) == n) ans += v[0]; else if (press(ans + v[1]) == n) ans += v[1]; else ans += v[2]; assert((int)ans.size() == n); return ans; } /*int main() { return 0; } */

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:8:6: error: 'press' was not declared in this scope
    8 |  if (press("AB") > 0) {
      |      ^~~~~
combo.cpp:26:11: error: 'press' was not declared in this scope
   26 |   int x = press(s);
      |           ^~~~~
combo.cpp:33:6: error: 'press' was not declared in this scope
   33 |  if (press(ans + v[0]) == n) ans += v[0];
      |      ^~~~~