Submission #1034715

#TimeUsernameProblemLanguageResultExecution timeMemory
1034715DeathIsAweCombo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; string guess_sequence(int n) { vector<char> letters; string p = ""; string ptemp = ""; int temp = press("AB"); if (temp == 2) { p += 'A'; } else if (temp == 1) { temp = press("A"); if (temp == 1) { p += 'A'; } else { p += 'B'; } } else { temp = press("X"); if (temp == 1) { p += 'X'; } else { p += 'Y'; } } if ('A' != p[0]) { letters.push_back('A'); } if ('B' != p[0]) { letters.push_back('B'); } if ('X' !=p[0]) { letters.push_back('X'); } if ('Y' !=p[0]) { letters.push_back('Y'); } int count; while (p.size() < n-1) { ptemp = ""; count = 0; for (int i=0;i<3;i++) { ptemp += p; ptemp += letters[0]; ptemp += letters[i]; } ptemp += p; ptemp += letters[1]; temp=press(ptemp); if (temp == p.size()) { p+=letters[2]; } else if (temp == p.size()+1) { p += letters[1]; } else { p += letters[0]; } } ptemp = p + letters[0]; if (press(ptemp) == n) { p += letters[0]; return p; } else { ptemp = p + letters[1]; if (press(ptemp) == n) { p += letters[1]; return p; } else { p += letters[2]; return p; } } }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:8:14: error: 'press' was not declared in this scope
    8 |   int temp = press("AB");
      |              ^~~~~
combo.cpp:42:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   42 |   while (p.size() < n-1) {
      |          ~~~~~~~~~^~~~~
combo.cpp:54:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     if (temp == p.size()) {
      |         ~~~~~^~~~~~~~~~~
combo.cpp:56:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     } else  if (temp == p.size()+1) {
      |                 ~~~~~^~~~~~~~~~~~~
combo.cpp:5:16: warning: control reaches end of non-void function [-Wreturn-type]
    5 |   vector<char> letters;
      |                ^~~~~~~