Submission #849541

#TimeUsernameProblemLanguageResultExecution timeMemory
849541Bach21Combo (IOI18_combo)C++14
100 / 100
18 ms1960 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; const int m=4; string gue="ABXY"; string guess_sequence(int N) { string s; int tmp=press("AB"); if (tmp!=0) { tmp=press("A"); if (tmp!=0) { s+='A'; gue.erase(gue.begin()); } else { s+='B'; gue.erase(gue.begin()+1); } } else { tmp=press("X"); if (tmp!=0) { s+='X'; gue.erase(gue.begin()+2); } else { s+='Y'; gue.erase(gue.begin()+3); } } for (int i=0;i<N-2;i++) { string tmp=""; for (int j=0;j<gue.size();j++) { tmp+=s+gue[0]+gue[j]; } tmp+=s+gue[1]; int len=press(tmp); if (len==i+3) { s+=gue[0]; } else if (len==i+2) { s+=gue[1]; } else s+=gue[2]; } if (N>1) { for (int i=0;i<gue.size()-1;i++) { string tmp=s; tmp+=gue[i]; int len=press(tmp); if (len==N) { s+=gue[i]; break; } if (i==gue.size()-2) s+=gue[gue.size()-1]; } } return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:37:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for (int j=0;j<gue.size();j++)
      |                      ~^~~~~~~~~~~
combo.cpp:53:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |         for (int i=0;i<gue.size()-1;i++)
      |                      ~^~~~~~~~~~~~~
combo.cpp:63:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |             if (i==gue.size()-2) s+=gue[gue.size()-1];
      |                 ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...