Submission #441094

#TimeUsernameProblemLanguageResultExecution timeMemory
441094beferithCombo (IOI18_combo)C++14
100 / 100
38 ms680 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N){ mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); vector<string> chr = {"A","B","X","Y"}; string curr = ""; for(int i=0;i<N;i++){ shuffle(chr.begin(),chr.end(),rng); if(i == 0){ int half = press("AB"); if(half == 0){ int quad = press("X"); if(quad){ curr += "X"; }else{ curr += "Y"; } }else{ int quad = press("A"); if(quad){ curr += "A"; }else{ curr += "B"; } } chr.erase(find(chr.begin(),chr.end(),curr)); }else if(i == N-1){ bool found = false; for(int j=0;j<chr.size()-1;j++){ if(press(curr + chr[j]) == i+1){ curr += chr[j]; found = true; break; } } if(!found){ curr += chr[chr.size()-1]; } }else{ string ask = (curr+chr[0]) + (curr+chr[1]+chr[0]) + (curr+chr[1]+chr[1]) + (curr+chr[1]+chr[2]); int query = press(ask); if(query == i){ curr += chr[2]; }else if(query == i+2){ curr += chr[1]; }else{ curr += chr[0]; } } } return curr; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:34:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |             for(int j=0;j<chr.size()-1;j++){
      |                         ~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...