Submission #706741

#TimeUsernameProblemLanguageResultExecution timeMemory
706741Yell0Combo (IOI18_combo)C++17
100 / 100
28 ms528 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int N) { vector<char> ch={'A','B','X','Y'}; if(press("AB")) { if(press("B")) swap(ch[0],ch[1]); } else { if(press("X")) swap(ch[0],ch[2]); else swap(ch[0],ch[3]); } string ans=""; ans.push_back(ch[0]); for(int i=1;i<N-1;++i) { int r=press(ans+ch[1]+ans+ch[2]+ch[1]+ans+ch[2]+ch[2]+ans+ch[2]+ch[3]); if(r==i) ans.push_back(ch[3]); else if(r==i+1) ans.push_back(ch[1]); else ans.push_back(ch[2]); } if(ans.size()<N) { if(press(ans+ch[1])==N) ans.push_back(ch[1]); else { if(press(ans+ch[2])==N) ans.push_back(ch[2]); else ans.push_back(ch[3]); } } return ans; }

Compilation message (stderr)

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