Submission #488872

#TimeUsernameProblemLanguageResultExecution timeMemory
4888721neCombo (IOI18_combo)C++14
5 / 100
1 ms200 KiB
#include "combo.h" #include<bits/stdc++.h> using namespace std; std::string guess_sequence(int n) { string a,b,x,y; a+='A'; b+='B'; x+='X'; y+='Y'; string c; string s; if (press(a)==1){ c = "BXY"; s+='A'; } else if (press(b)==1){ c = "AXY"; s+='B'; } else if (press(x)==1){ c = "BAY"; s+='X'; } else{ c = "BXA"; s+='Y'; } if (n==1){ return s; } a = s; b = s; a+=c[0]; b+=c[1]; string q; q+=b; for (auto x:c){ a+=x; q+=a; a.pop_back(); } int temp = press(q); if (temp==2){ s+=c[1]; } else if (temp==3){ s+=c[0]; } else{ s+=c[2]; } for (int i = 2;i<n-1;++i){ q.clear(); q+=s; q+=c[0]; string t; t+=s; t+=c[1]; for (auto x:c){ t+=x; q+=t; t.pop_back(); } temp = press(q); if (temp == s.length()+1){ s+=c[0]; } else if(temp==s.length()+2){ s+=c[1]; } else s+=c[2]; } for (auto x:c){ s+=x; if (press(s)==n){ return s; } s.pop_back(); } return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:65:12: 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 (temp == s.length()+1){
      |       ~~~~~^~~~~~~~~~~~~~~
combo.cpp:68:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |   else if(temp==s.length()+2){
      |           ~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...