Submission #1032477

#TimeUsernameProblemLanguageResultExecution timeMemory
1032477ThommyDBCombo (IOI18_combo)C++17
100 / 100
20 ms1828 KiB
#include "combo.h" #include<bits/stdc++.h> using namespace std; string guess_sequence(int N) { string p = ""; if(press("AB")>=1){ if(press("A") >= 1) p+="A"; else p+="B"; } else{ if(press("X") >= 1) p+="X"; else p+="Y"; } if(N==1)return p; vector<char> a; for(auto u : "ABXY"){ if(u!=p[0]) a.push_back(u); } for(int i = 1; i<N-1; i++){ string s = ""; s += p; s += a[0]; s += p; s += a[1]; s += a[0]; s += p; s += a[1]; s += a[1]; s += p; s += a[1]; s += a[2]; int v = press(s); if(v == p.length() +1) p+=a[0]; else if(v==p.length()+2) p+=a[1]; else p+=a[2]; } if(press(p+a[0]) == N) p+=a[0]; else if(press(p+a[1])==N) p+=a[1]; else p+=a[2]; return p; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:28:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     if(v == p.length() +1) p+=a[0];
      |        ~~^~~~~~~~~~~~~~~~
combo.cpp:29:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     else if(v==p.length()+2) p+=a[1];
      |             ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...