Submission #879160

#TimeUsernameProblemLanguageResultExecution timeMemory
879160StiffCombo (IOI18_combo)C++17
100 / 100
14 ms1716 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int n) { string tmp = "AB"; string ans, pos; int len = press(tmp); if (len == 2) { ans = "A"; pos = "BXY"; } else if (len == 1) { if (press("A") == 1) ans = "A", pos = "BXY"; else ans = "B", pos = "AXY"; } else { if (press("X") == 1) ans = "X", pos = "ABY"; else ans = "Y", pos = "ABX"; } for (int i = 2; i < n; i++) { tmp = ans + pos[0] + ans + pos[1] + pos[0] + ans + pos[1] + pos[1] + ans + pos[1] + pos[2]; len = press(tmp); if (len == ans.size() + 1) { ans += pos[0]; } else if (len == ans.size() + 2) { ans += pos[1]; } else { ans += pos[2]; } } if (n == 1) return ans; if (press(ans + pos[0]) == ans.size() + 1) ans += pos[0]; else if (press(ans + pos[1]) == ans.size() + 1) ans += pos[1]; else ans += pos[2]; return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:28:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     if (len == ans.size() + 1) {
      |         ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:30:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     } else if (len == ans.size() + 2) {
      |                ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:40:27: 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(ans + pos[0]) == ans.size() + 1)
      |       ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:42:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   else if (press(ans + pos[1]) == ans.size() + 1)
      |            ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...