Submission #777068

#TimeUsernameProblemLanguageResultExecution timeMemory
777068GusterGoose27Combo (IOI18_combo)C++17
100 / 100
26 ms620 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int n) { string cur = ""; char conv[4]; conv[0] = 'A'; conv[1] = 'B'; conv[2] = 'X'; conv[3] = 'Y'; map<char, int> anticonv; for (int i = 0; i < 4; i++) anticonv[conv[i]] = i; int s; while (cur.size() < n) { if (cur.empty() || cur.size() == n-1) { if (press(cur+'A'+cur+'B') >= cur.size()+1) { if (press(cur+'A') == cur.size()+1) cur += 'A'; else cur += 'B'; } else { if (press(cur+'X') == cur.size()+1) cur += 'X'; else cur += 'Y'; } if (cur.size() == 1) s = anticonv[cur[0]]; continue; } string res = cur+conv[(s+2)%4]; for (int i = 1; i <= 3; i++) res += cur+conv[(s+3)%4]+conv[(s+i)%4]; cur += conv[(s+1+press(res)-cur.size())%4]; } return cur; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:17:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   17 |     while (cur.size() < n) {
      |            ~~~~~~~~~~~^~~
combo.cpp:18:39: 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 (cur.empty() || cur.size() == n-1) {
      |                            ~~~~~~~~~~~^~~~~~
combo.cpp:19:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |             if (press(cur+'A'+cur+'B') >= cur.size()+1) {
      |                 ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:20:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |                 if (press(cur+'A') == cur.size()+1) cur += 'A';
      |                     ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:24:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |                 if (press(cur+'X') == cur.size()+1) cur += 'X';
      |                     ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:16:9: warning: 's' may be used uninitialized in this function [-Wmaybe-uninitialized]
   16 |     int s;
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...