Submission #1105125

#TimeUsernameProblemLanguageResultExecution timeMemory
1105125thelegendary08Combo (IOI18_combo)C++14
100 / 100
29 ms1872 KiB
#include "combo.h" #include<bits/stdc++.h> using namespace std; std::string guess_sequence(int N) { int r = press("AB"); char f; if(r >= 1){ r = press("A"); if(r == 1)f = 'A'; else f = 'B'; } else{ r = press("X"); if(r == 1)f = 'X'; else f = 'Y'; } vector<char>cs = {'A', 'B', 'X', 'Y'}; vector<char>e; for(auto u : cs){ if(u != f)e.push_back(u); } //for(auto u : e)cout<<u<<' '; //cout<<'\n'; string s = ""; s+=f; //cout<<s<<'\n'; for(int i = 1; i<N-1; i++){ string quer = ""; quer += s; quer += e[0]; //cout<<quer<<" QUER"<<'\n'; for(auto u : e){ quer += s; quer += e[1]; quer += u; } //cout<<quer<<" QUER"<<'\n'; r = press(quer); if(r == s.size()){ s += e[2]; } else if(r == s.size() + 1){ s += e[0]; } else s += e[1]; } if(N != 1){ r = press(s + e[0]); if(r == N){ s += e[0]; } else{ r = press(s + e[1]); if(r == N){ s += e[1]; } else s += e[2]; } } return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:39:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     if(r == s.size()){
      |        ~~^~~~~~~~~~~
combo.cpp:42:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     else if(r == s.size() + 1){
      |             ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...