Submission #117126

#TimeUsernameProblemLanguageResultExecution timeMemory
117126exqtCombo (IOI18_combo)C++17
100 / 100
57 ms536 KiB
#include <vector> #include <iostream> using namespace std; #include "combo.h" string guess_sequence(int N) { string S = ""; auto guess1 = [&S]() { if(press(S+"A"+S+"B") > S.length()) if(press(S+"A") > S.length()) S += 'A'; else S += 'B'; else if(press(S+"X") > S.length()) S += 'X'; else S += 'Y'; }; guess1(); if(S.length() == N) return S; vector<char> candi; for(char c : "ABXY") { if(c != S[0]) candi.push_back(c); } auto guess2 = [&S, &candi]() { int t = press( S+candi[0]+candi[0]+ S+candi[0]+candi[1]+ S+candi[0]+candi[2]+ S+candi[1] ); if(t == S.length()+2) S += candi[0]; else if(t == S.length()+1) S += candi[1]; else S += candi[2]; }; for(int i=1; i<N-1; i++) guess2(); guess1(); return S; }

Compilation message (stderr)

combo.cpp: In lambda function:
combo.cpp:11:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     if(press(S+"A"+S+"B") > S.length())
      |        ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
combo.cpp:12:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |       if(press(S+"A") > S.length()) S += 'A'; else S += 'B';
      |          ~~~~~~~~~~~~~^~~~~~~~~~~~
combo.cpp:14:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |       if(press(S+"X") > S.length()) S += 'X'; else S += 'Y';
      |          ~~~~~~~~~~~~~^~~~~~~~~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:18:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |   if(S.length() == N) return S;
      |      ~~~~~~~~~~~^~~~
combo.cpp: In lambda function:
combo.cpp:33:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     if(t == S.length()+2) S += candi[0];
      |        ~~^~~~~~~~~~~~~~~
combo.cpp:34:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     else if(t == S.length()+1) S += candi[1];
      |             ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...