Submission #96083

#TimeUsernameProblemLanguageResultExecution timeMemory
96083bogdan10bosCombo (IOI18_combo)C++14
100 / 100
71 ms796 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; const char ltr[] = {'A', 'B', 'X', 'Y'}; string guess_sequence(int N) { char start = 0; if(press("AB")) { if(press("A")) start = 'A'; else start = 'B'; } else { if(press("X")) start = 'X'; else start= 'Y'; } string pfx = ""; pfx += start; if(N == 1) return pfx; vector<char> l; for(int i = 0; i < 4; i++) if(ltr[i] != start) l.push_back(ltr[i]); for(int i = 1; i + 1 < N; i++) { string qry = (pfx + l[0]) + (pfx + l[1] + l[0]) + (pfx + l[1] + l[1]) + (pfx + l[1] + l[2]); int prs = press(qry); if(prs == pfx.size()) pfx += l[2]; else if(prs == pfx.size() + 1) pfx += l[0]; else pfx += l[1]; } if(press(pfx + l[0] + pfx + l[1]) == pfx.size()) pfx += l[2]; else { if(press(pfx + l[0]) == pfx.size()) pfx += l[1]; else pfx += l[0]; } return pfx; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:35:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         if(prs == pfx.size())    pfx += l[2];
      |            ~~~~^~~~~~~~~~~~~
combo.cpp:36:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         else if(prs == pfx.size() + 1)   pfx += l[0];
      |                 ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:40:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     if(press(pfx + l[0] + pfx + l[1]) == pfx.size())  pfx += l[2];
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:43:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         if(press(pfx + l[0]) == pfx.size()) pfx += l[1];
      |            ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...