제출 #204458

#제출 시각아이디문제언어결과실행 시간메모리
204458bogdan_ogorodniy콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> // #include "combo.h" using namespace std; string need; // int press(string p) { // string s = need + "#" + p; // int n = (int) s.length(); // vector<int> pi (n); // for (int i = 1; i < n; ++i) { // int j = pi[i - 1]; // while (j > 0 && s[i] != s[j]) // j = pi[j - 1]; // if (s[i] == s[j]) ++j; // pi[i] = j; // } // int ans = 0; // for (int i = need.size(); i < s.size(); i++) { // ans = max(ans, pi[i]); // } // cout << s << '\t' << ans << '\n'; // return ans; // } string make_to(string s, int n) { for (int i = s.size(); i <= n; i++) { s.push_back(s[0]); } return s; } vector <char> ch = {'A', 'B', 'X', 'Y'}; string guess_sequence(int n) { string ans; for (int i = 0; i < n; i++) { int best = 0; string nans; vector <char> cc; for (auto it : ch) { if (i&&it==ans[0]) continue; cc.push_back(it); } if (cc.size() == 3) { string tmp1 = ans, tmp2 = ans, tmp3 = ans; tmp1.push_back(cc[0]); tmp2.push_back(cc[1]); tmp3.push_back(cc[2]); int resp = press(make_to(tmp1, n) + make_to(tmp2, n)); if (resp == i + 1) { resp = press(make_to(tmp1, n)); if (resp == i + 1) nans = tmp1; else nans = tmp2; } else { nans = tmp3; } } else { string tmp1 = ans, tmp2 = ans, tmp3 = ans, tmp4 = ans; tmp1.push_back(cc[0]); tmp2.push_back(cc[1]); tmp3.push_back(cc[2]); tmp4.push_back(cc[3]); int resp = press(make_to(tmp1, n) + make_to(tmp2, n)); if (resp == i + 2) { i++; nans = tmp1; nans.push_back(tmp2[0]); } else if (resp == i + 1) { resp = press(make_to(tmp1, n)); if (resp == i + 1) nans = tmp1; else nans = tmp2; } else { resp = press(make_to(tmp3, n)); if (resp == i + 1) nans = tmp3; else nans = tmp4; } } ans = nans; } return ans; } // signed main() { // cin >> need; // cout << guess_sequence(need.size()); // return 0; // }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:48:24: error: 'press' was not declared in this scope
   48 |             int resp = press(make_to(tmp1, n) + make_to(tmp2, n));
      |                        ^~~~~
combo.cpp:64:24: error: 'press' was not declared in this scope
   64 |             int resp = press(make_to(tmp1, n) + make_to(tmp2, n));
      |                        ^~~~~
combo.cpp:36:13: warning: unused variable 'best' [-Wunused-variable]
   36 |         int best = 0;
      |             ^~~~