Submission #79484

#TimeUsernameProblemLanguageResultExecution timeMemory
79484alextodoranCombo (IOI18_combo)C++14
100 / 100
49 ms524 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; /* string combo; int press(string p) { for(int i = 0; i < combo.size(); i++) { int ok1 = 0; for(int j = 0; j < p.size() - i; j++) { int ok = 1; for(int k = j; k <= j + i; k++) if(p[k] != combo[k - j]) { ok = 0; break; } if(ok == 1) { ok1 = 1; break; } } if(ok1 == 0) return i; } return combo.size(); }*/ string guess_sequence(int N) { string b[] = {"A", "B", "X", "Y"}; vector <string> b1; b1.clear(); string pref = ""; if(press("AX")) { if(press("A")) pref = "A"; else pref = "X"; } else { if(press("B")) pref = "B"; else pref = "Y"; } for(int i = 0; i < 4; i++) if(b[i] != pref) b1.push_back(b[i]); for(int i = 1; i < N - 1; i++) { int q = press(pref + b1[0] + pref + b1[1] + b1[0] + pref + b1[1] + b1[1] + pref + b1[1] + b1[2]); if(q == pref.size()) pref += b1[2]; else if(q == pref.size() + 1) pref += b1[0]; else pref += b1[1]; } if(N == 1) return pref; if(press(pref + b1[0] + pref + b1[1]) > pref.size()) { if(press(pref + b1[0]) > pref.size()) pref += b1[0]; else pref += b1[1]; } else pref += b1[2]; return pref; } /* int main() { cin >> combo; cout << guess_sequence(combo.size()); return 0; }*/

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:60:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |         if(q == pref.size())
      |            ~~^~~~~~~~~~~~~~
combo.cpp:62:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |         else if(q == pref.size() + 1)
      |                 ~~^~~~~~~~~~~~~~~~~~
combo.cpp:69:43: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |     if(press(pref + b1[0] + pref + b1[1]) > pref.size())
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:71:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |         if(press(pref + b1[0]) > pref.size())
      |            ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...