Submission #552897

#TimeUsernameProblemLanguageResultExecution timeMemory
552897fcmalkcinCombo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define ll int #define pll pair<ll,ll> #define ff first #define ss second //#define endl "\n" #define pb push_back #define F(i,a,b) for(ll i=a;i<=b;i++) const ll maxn=4e6+3000; const ll base=2e9; const ll mod= 1e9+7 ; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); /*ll press(string t) { cout <<t<<endl; ll x; cin>> x; return x; }*/ string guess_sequence(ll n) { ll p=press("AB"); set<char> st; st.insert('A'); st.insert('B'); st.insert('X'); st.insert('Y'); string res; if (p) { ll p=press("A"); if (p) st.erase('A'),res.pb('A'); else st.erase('B'),res.pb('B'); } else { ll p=press("X"); if (p) st.erase('X'),res.pb('X'); else st.erase('Y'),res.pb('Y'); } for (int i=2; i<=n-1; i++) { string pt; for (auto to:st) { pt+=res; pt.pb(*st.begin()); pt.pb(to); } ll cnt=0; for (auto to:st) { cnt++; if (cnt==2) { pt+=res; pt.pb(to); break; } } ll p=press(pt); ll h=0; if (p==res.length()+2) { h=1; } else if (p==res.length()+1) { h=2; } else { h=3; } cnt=0; for (auto to:st) { cnt++; if (cnt==h) { res.pb(to); } } } ll cnt=0; for (auto to:st) { string pt=res; pt.pb(to); if (press(pt)==n) { res=pt; break; } cnt++; if (cnt==3) break; } if (res.length()!=n) { auto it=st.end(); it--; res.pb(*it); } return res; } /*int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("t.inp","r")) { freopen("test.inp","r",stdin); freopen("test.out","w",stdout); } cout <<guess_sequence(7); }*/

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:27:10: error: 'press' was not declared in this scope
   27 |     ll p=press("AB");
      |          ^~~~~
combo.cpp:73:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |         if (p==res.length()+2)
      |             ~^~~~~~~~~~~~~~~~
combo.cpp:77:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |         else if (p==res.length()+1)
      |                  ~^~~~~~~~~~~~~~~~
combo.cpp:108:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  108 |     if (res.length()!=n)
      |         ~~~~~~~~~~~~^~~