Submission #574996

#TimeUsernameProblemLanguageResultExecution timeMemory
574996HackapieCombo (IOI18_combo)C++17
100 / 100
36 ms648 KiB
#include "combo.h" #include<bits/stdc++.h> using namespace std; std::string guess_sequence(int N){ set<char> s; s.insert('A'); s.insert('B'); s.insert('X'); s.insert('Y'); string res; string check; if(N==1){ if(press("A"))return "A"; else if(press("B")) return "B"; else if(press("X")) return "X"; else return "Y"; } int ans=press("AB"); if(ans){ if(press("A"))res+='A'; else res+='B'; }else{ if(press("X"))res+='X'; else res+='Y'; } s.erase(res[0]); for(auto x:s)check+=x; while(res.size()<N-1){ string ch=res+check[1]+res+check[2]+check[0]+res+check[2]+check[1]+res+check[2]+check[2]; res+=check[press(ch)-res.size()]; } if(press(res+check[0])==N){ res+=check[0]; }else if(press(res+check[1])==N){ res+=check[1]; }else res+=check[2]; return res; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:29:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |   while(res.size()<N-1){
      |         ~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...