Submission #112298

#TimeUsernameProblemLanguageResultExecution timeMemory
112298sochoCombo (IOI18_combo)C++14
5 / 100
2 ms244 KiB
#include <bits/stdc++.h> using namespace std; #include "combo.h" string guess_sequence(int N) { // return! string anchor; int ab = press("AB"); int oa = -1; int ox = -1; string rem; if (ab > 0) { // must be A or B anchor oa = press("A"); if (oa > 0) { anchor = "A"; rem = "BXY"; } else { anchor = "B"; rem = "AXY"; } } else { // must be X or Y anchor ox = press("X"); if (ox > 0) { anchor = "X"; rem = "ABY"; } else { anchor = "Y"; rem = "ABX"; } } // cout << anchor; string pref = anchor; for (int i=1; i<N-1; i++) { string query = pref + rem[0] + pref + rem[1] + rem[2] + pref + rem[1] + rem[0] + pref + rem[1] + rem[1]; //cout << "pres: " << query << endl; int response = press(query); //cout << " > got: " << response << endl; if (response == pref.length()) { pref += rem[2]; } else if (response == pref.length() + 1) { pref += rem[0]; } else { pref += rem[1]; } } //cout << "give: " << pref << endl; string ender = pref + rem[0] + pref + rem[1]; int res = press(ender); if (res == pref.size()) { pref += rem[2]; } else { string ender2 = pref + rem[0]; int resp = press(ender2); if (resp == pref.size()) { pref += rem[1]; } else { pref += rem[0]; } } return pref; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:46:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         if (response == pref.length()) {
      |             ~~~~~~~~~^~~~~~~~~~~~~~~~
combo.cpp:49:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |         else if (response == pref.length() + 1) {
      |                  ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
combo.cpp:59:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     if (res == pref.size()) {
      |         ~~~~^~~~~~~~~~~~~~
combo.cpp:65:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |         if (resp == pref.size()) {
      |             ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...