제출 #161134

#제출 시각아이디문제언어결과실행 시간메모리
161134InkretBear콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; /*int press(string a){ int x; cout << "querying " << a << endl; cin >> x; return x; }*/ string guess_sequence(int n){ int q=press("AB"),w=press("AX"); char s[4]={'A','B','X','Y'}; if (q && w){ swap(s[0],s[3]); } if (q && !w){ swap(s[1],s[3]); } if (!q && w){ swap(s[2],s[3]); } string res,u; res.push_back(s[3]); for (int i=1;i<n-1;++i){ u.clear(); for (int j=0;j<i;++j){ u.push_back(res[j]); } u.push_back(s[1]); for (int j=0;j<i;++j){ u.push_back(res[j]); } u.push_back(s[0]); u.push_back(s[0]); for (int j=0;j<i;++j){ u.push_back(res[j]); } u.push_back(s[0]); u.push_back(s[2]); for (int j=0;j<i;++j){ u.push_back(res[j]); } u.push_back(s[0]); u.push_back(s[1]); q=press(u); if (q==i){ res.push_back(s[2]); } if (q==i+1){ res.push_back(s[1]); } if (q==i+2){ res.push_back(s[0]); } } u.clear(); for (int i=0;i<n-1;++i){ u.push_back(res[i]); } u.push_back(s[0]); q=press(u); u.clear(); for (int i=0;i<n-1;++i){ u.push_back(res[i]); } u.push_back(s[1]); w=press(u); if (q==n){ res.push_back(s[0]); } else if (w==n){ res.push_back(s[1]); } else { res.push_back(s[2]); } return res; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:12:8: error: 'press' was not declared in this scope
   12 |  int q=press("AB"),w=press("AX");
      |        ^~~~~
combo.cpp:14:11: error: 'w' was not declared in this scope
   14 |  if (q && w){
      |           ^
combo.cpp:17:12: error: 'w' was not declared in this scope
   17 |  if (q && !w){
      |            ^
combo.cpp:20:12: error: 'w' was not declared in this scope
   20 |  if (!q && w){
      |            ^
combo.cpp:68:2: error: 'w' was not declared in this scope
   68 |  w=press(u);
      |  ^