Submission #1236499

#TimeUsernameProblemLanguageResultExecution timeMemory
1236499em4ma2Combo (IOI18_combo)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> //#include "combo.h" using namespace std; #define pb push_back #define ll long long const int off=1<<19; const int inf=1e9+4; const int mxsz=2e5+4; int q(int x,int y){ cout<<"? "<<x<<" "<<y<<endl<<flush; int xx; cin>>xx; return xx; } void ans(char c){ cout<<"! "<<c<<endl<<flush; } // int N=5; // std::string S="ABXYY"; // constexpr int MAX_N = 2000; // constexpr int MAX_NUM_MOVES = 8000; // int num_moves; // void wrong_answer(const char *MSG) { // printf("Wrong Answer: %s\n", MSG); // exit(0); // } // int press(std::string p) { // if (++num_moves > MAX_NUM_MOVES) { // wrong_answer("too many moves"); // } // int len = p.length(); // if (len > 4 * N) { // wrong_answer("invalid press"); // } // for (int i = 0; i < len; ++i) { // if (p[i] != 'A' && p[i] != 'B' && p[i] != 'X' && p[i] != 'Y') { // wrong_answer("invalid press"); // } // } // int coins = 0; // for (int i = 0, j = 0; i < len; ++i) { // if (j < N && S[j] == p[i]) { // ++j; // } else if (S[0] == p[i]) { // j = 1; // } else { // j = 0; // } // coins = std::max(coins, j); // } // return coins; // } string guess_sequence(int n) { string p = "XY"; int x; //cout<<p<<endl; x=press(p); if (x>0){ p="X"; x=press(p); if (x==0){ p="Y"; } }else{ p="A"; x=press(p); if (x==0){ p="B"; } } string chs="ABXY"; for (int i=0;i<4;i++){ if (chs[i]==p[0])chs[i]='#'; } string k; for (auto x:chs){ if (x!='#')k.pb(x); } int cnt=1; int tmp=n-2; int j=0; while (tmp--){ string s=p+k[j] +p+k[j+1]+k[j] +p+k[j+1]+k[j+1] +p+k[j+1]+k[j+2]; x=press(s); if (x==cnt+0){ p+=k[j+2]; }else if (x==cnt+1){ p+=k[j]; }else{ p+=k[j+1]; } cnt++; } string s=p+k[j] +p+k[j+1]; x=press(s); if (x==cnt+1){ s=p+k[j]; x=press(s); if (x==cnt){ s=p+k[j+1]; } }else{ s=p+k[j+2]; } return s; } // int main(){ // int n; // cin>>n; // cout<<guess_sequence(n)<<endl; // return 0; // }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:68:7: error: 'press' was not declared in this scope
   68 |     x=press(p);
      |       ^~~~~