Submission #500484

#TimeUsernameProblemLanguageResultExecution timeMemory
500484KhizriCombo (IOI18_combo)C++17
100 / 100
30 ms576 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string x="ABXY",y="ABXY"; int k=0; char ask(string ans,int n){ string p=""; p+=ans; p+=x[0]; for(int i=0;i<x.size();i++){ p+=ans; p+=x[1]; p+=x[i]; } int k=press(p); if(k==ans.size()+1){ return x[0]; } else if(k==ans.size()+2){ return x[1]; } else{ return x[2]; } } string guess_sequence(int n) { string ans=""; if(press("AB")){ if(press("A")){ ans+='A'; } else{ ans+='B'; } } else{ if(press("X")){ ans+='X'; } else{ ans+='Y'; } } for(int i=0;i<x.size();i++){ if(x[i]==ans[0]){ x.erase(x.begin()+i); break; } } for(int i=1;i<n-1;i++){ ans+=ask(ans,n); } if(n==1){ return ans; } string a=ans,b=ans; a+=x[0]; b+=x[1]; if(press(a)==n){ ans+=x[0]; } else if(press(b)==n){ ans+=x[1]; } else{ ans+=x[2]; } return ans; }

Compilation message (stderr)

combo.cpp: In function 'char ask(std::string, int)':
combo.cpp:10:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i=0;i<x.size();i++){
      |                 ~^~~~~~~~~
combo.cpp:16:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     if(k==ans.size()+1){
      |        ~^~~~~~~~~~~~~~
combo.cpp:19:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     else if(k==ans.size()+2){
      |             ~^~~~~~~~~~~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:44:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for(int i=0;i<x.size();i++){
      |                 ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...