Submission #76493

#TimeUsernameProblemLanguageResultExecution timeMemory
76493igziCombo (IOI18_combo)C++17
100 / 100
59 ms560 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; /* int press(string p){ cout<<p<<endl; int k; cin>>k; return k; }*/ string guess_sequence(int N){ vector <char> v={'A','B','X','Y'}; string p,ans; p="AB"; if(press(p)){ p.clear(); p="A"; if(press(p)){ v.erase(v.begin()); ans="A"; } else v.erase(v.begin()+1), ans="B"; } else{ p.clear(); p="X"; if(press(p)){ v.erase(v.begin()+2); ans="X"; } else v.erase(v.begin()+3), ans="Y"; } while(ans.size()<N-1){ p.clear(); p+=ans+v[0]+v[0]; p+=ans+v[0]+v[1]; p+=ans+v[0]+v[2]; p+=ans+v[1]; int tmp=press(p); if(tmp==ans.size()) ans+=v[2]; if(tmp==ans.size()+1) ans+=v[1]; if(tmp==ans.size()+2) ans+=v[0]; } if(ans.size()==N) return ans; p.clear(); p=ans+v[0]; if(press(p)==N) return p; p.clear(); p=ans+v[1]; if(press(p)==N) return p; p.clear(); p=ans+v[2]; return p; } /* 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:36:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 | while(ans.size()<N-1){
      |       ~~~~~~~~~~^~~~
combo.cpp:43:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     if(tmp==ans.size()) ans+=v[2];
      |        ~~~^~~~~~~~~~~~
combo.cpp:44:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     if(tmp==ans.size()+1) ans+=v[1];
      |        ~~~^~~~~~~~~~~~~~
combo.cpp:45:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     if(tmp==ans.size()+2) ans+=v[0];
      |        ~~~^~~~~~~~~~~~~~
combo.cpp:47:14: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 | if(ans.size()==N) return ans;
      |    ~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...