Submission #823632

#TimeUsernameProblemLanguageResultExecution timeMemory
823632SoulKnightCombo (IOI18_combo)C++17
100 / 100
25 ms688 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define ln '\n' string B[4] = {"A", "B", "X", "Y"}; string ans, g; int res; string guess_sequence(int n){ res = press("AB"); if (res == 2) ans += "A"; else if (res == 1){ ans = ((press("A"))? "A": "B"); } else { ans = ((press("X"))? "X": "Y"); } for (int i = 0; i < 4; i++){ if (ans.substr(0, 1) == B[i]) {swap(B[i], B[3]); break;} } for (int i = 1; i < n-1; i++){ g = ans + B[0] + B[0] + ans + B[0] + B[1] + ans + B[0] + B[2] + ans + B[1]; res = press(g); if (res == ans.size() + 2) ans += B[0]; else if (res == ans.size() + 1) ans += B[1]; else ans += B[2]; } if (n > 1){ res = press(ans + B[0]); if (res == ans.size() + 1) ans += B[0]; else { ans += ((press(ans + B[1]) == ans.size() + 1)? B[1]: B[2]); } } return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:30:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         if (res == ans.size() + 2) ans += B[0];
      |             ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:31:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         else if (res == ans.size() + 1) ans += B[1];
      |                  ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:37:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         if (res == ans.size() + 1) ans += B[0];
      |             ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:39:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |             ans += ((press(ans + B[1]) == ans.size() + 1)? B[1]: B[2]);
      |                      ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...