Submission #714707

#TimeUsernameProblemLanguageResultExecution timeMemory
714707bin9638Combo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define N 510 #define ll long long #define ii pair<int,int> #define fs first #define sc second #define pb push_back #define iii pair<int,ii> #ifdef SKY string s; int press(string p) { //cout<<s<<" "<<p<<endl; for(int sz=s.size();sz>=1;sz--) { for(int i=0;i+sz-1<p.size();i++) if(s.substr(0,sz)==p.substr(i,sz)) return sz; } return 0; } #endif vector<char>kt; string guess_sequence(int n) { char start; if(press("XY")==0) { if(press("A")==0) start='B'; else start='A'; }else { if(press("X")==0) start='Y'; else start='X'; } vector<char>cc={'A','B','X','Y'}; for(auto ch:cc) if(ch!=start) kt.pb(ch); string kq=""; kq.pb(start); for(int i=1;i<n-1;i++) { string ask=""; ask+=kq+kt[0]; ask+=kq+kt[1]+kt[0]+kq+kt[1]+kt[1]+kq+kt[1]+kt[2]; int val=press(ask); if(val==kq.size()) { kq.pb(kt[2]); continue; } if(val==kq.size()+1) { kq.pb(kt[0]); continue; } if(val==kq.size()+2) { kq.pb(kt[1]); continue; } } if(press(kq+kt[0]+kq+kt[1])==kq.size()+1) { if(press(kq+kt[0])==kq.size()+1) kq.pb(kt[0]); else kq.pb(kt[1]); }else kq.pb(kt[2]); return kq; } #ifdef SKY int main() { freopen("A.inp","r",stdin); freopen("A.out","w",stdout); ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin>>s; cout<<guess_sequence(s.size()); return 0; } #endif // SKY

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:32:8: error: 'press' was not declared in this scope
   32 |     if(press("XY")==0)
      |        ^~~~~
combo.cpp:54:17: error: 'press' was not declared in this scope
   54 |         int val=press(ask);
      |                 ^~~~~
combo.cpp:55:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         if(val==kq.size())
      |            ~~~^~~~~~~~~~~
combo.cpp:60:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |         if(val==kq.size()+1)
      |            ~~~^~~~~~~~~~~~~
combo.cpp:65:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |         if(val==kq.size()+2)
      |            ~~~^~~~~~~~~~~~~
combo.cpp:71:8: error: 'press' was not declared in this scope
   71 |     if(press(kq+kt[0]+kq+kt[1])==kq.size()+1)
      |        ^~~~~