Submission #106216

#TimeUsernameProblemLanguageResultExecution timeMemory
106216tictaccatCombo (IOI18_combo)C++14
100 / 100
52 ms540 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; vector<char> chars {'A','B','X','Y'}; std::string guess_sequence(int N) { srand(time(NULL)); string ans = ""; //find first character, 2 guess char firstChar; if (press(ans+chars[0]+chars[1]) > 0) { if (press(ans+chars[0]) > 0) { firstChar = chars[0]; } else firstChar = chars[1]; } else { if (press(ans+chars[2]) > 0) { firstChar = chars[2]; } else firstChar = chars[3]; } chars.erase(remove(chars.begin(),chars.end(),firstChar),chars.end()); ans += firstChar; //each character, 1 guess while (4*ans.size()+7 <= 4*N) { //while strategy works int z = press(ans+chars[0]+ans+chars[1]+chars[0]+ans+chars[1]+chars[1]+ans+chars[1]+chars[2]) - ans.size(); // cout << "guess: " << (ans+chars[0]+ans+chars[1]+chars[0]+ans+chars[1]+chars[1]+ans+chars[1]+chars[2]) << " " << z; if (z == 2) { ans += chars[1]; } else if (z == 1) { ans += chars[0]; } else { ans += chars[2]; } // cout << ",new: " << ans << "\n"; } while (ans.size() < N) { if (press(ans+chars[0])-ans.size() > 0) { ans += chars[0]; } else if (press(ans+chars[1])-ans.size() > 0) ans += chars[1]; else ans += chars[2]; } // cout << ans << "\n"; return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:37:25: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |   while (4*ans.size()+7 <= 4*N) { //while strategy works
      |          ~~~~~~~~~~~~~~~^~~~~~
combo.cpp:58:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   58 |   while (ans.size() < N) {
      |          ~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...