Submission #516940

#TimeUsernameProblemLanguageResultExecution timeMemory
516940AngusWongCombo (IOI18_combo)C++17
100 / 100
28 ms600 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int n){ string s="ABXY", ans=""; if (press("AB")){ if (press("A")) ans="A", s="BXY"; else ans="B", s="AXY"; }else{ if (press("X")) ans="X", s="ABY"; else ans="Y", s="ABX"; } if (n==1) return ans; for (int i=2; i<n; i++){ int t=press(ans+s[0]+s[0]+ans+s[0]+s[1]+ans+s[0]+s[2]+ans+s[1]); if (t==i+1) ans+=s[0]; else if (t==i) ans+=s[1]; else ans+=s[2]; } for (int i=0; i<=1; i++){ if (press(ans+s[i])==n){ ans+=s[i]; break; } } if (ans.length()!=n) ans+=s[2]; return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:27:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |     if (ans.length()!=n) ans+=s[2];
      |         ~~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...