Submission #113499

#TimeUsernameProblemLanguageResultExecution timeMemory
113499Mamnoon_SiamCombo (IOI18_combo)C++17
5 / 100
56 ms556 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string ret; vector<char> R = {'A', 'B', 'X', 'Y'}; set<char> r(R.begin(), R.end()); if(press("AB")) { if(press("A")) ret += "A", r.erase('A'); else ret += "B", r.erase('B'); } else { if(press("X")) ret += "X", r.erase('X'); else ret += "Y", r.erase('Y'); } if(N == 1) return ret; R = vector<char>(r.begin(), r.end()); for(int i = 2; i < N; i++) { string tmp; tmp += ret, tmp += R[0]; for(char ch : R) { tmp += ret, tmp += R[1], tmp += ch; } int rep = press(tmp); if(rep == ret.size()) ret += R[2]; else if(rep == ret.size() + 1) ret += R[0]; else ret += R[1]; } for(int k = 0; k < 2; k++) { string tmp = ret; tmp += R[k]; if(press(tmp) == N) { ret += R[k]; break; } } if(ret.size() != N) ret += R[2]; return ret; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:25:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         if(rep == ret.size()) ret += R[2];
      |            ~~~~^~~~~~~~~~~~~
combo.cpp:26:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         else if(rep == ret.size() + 1) ret += R[0];
      |                 ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:37:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |     if(ret.size() != N) ret += R[2];
      |        ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...