Submission #132116

#TimeUsernameProblemLanguageResultExecution timeMemory
132116Tuk1352Combo (IOI18_combo)C++11
100 / 100
50 ms784 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { int r; string s1, s2, s3, s4, s, S; map <int, char> Ma; Ma[0] = 'A'; Ma[1] = 'B'; Ma[2] = 'X'; Ma[3] = 'Y'; s = "AB"; r = press(s); if (r >= 1) { s = "A"; r = press(s); if (r == 0) { Ma[1] = 'A'; Ma[0] = 'B'; S = "B"; } else { S = "A"; } } else { s = "X"; r = press(s); if (r == 1) { Ma[0] = 'X'; Ma[2] = 'A'; S = "X"; } else { Ma[0] = 'Y'; Ma[3] = 'A'; S = "Y"; } } for (int i = 1; i < N-1; i++) { s1 = S + Ma[1]; s2 = S + Ma[2] + Ma[1]; s3 = S + Ma[2] + Ma[2]; s4 = S + Ma[2] + Ma[3]; s = s1 + s2 + s3 + s4; r = press(s); if (r == S.length()) { S += Ma[3]; } else if (r == S.length() + 1) { S += Ma[1]; } else { S += Ma[2]; } } if (N >= 2) { s = S + Ma[1]; r = press(s); if (r == N) { S += Ma[1]; return S; } s = S + Ma[2]; r = press(s); if (r == N) { S += Ma[2]; return S; } S += Ma[3]; } return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:57:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |         if (r == S.length())
      |             ~~^~~~~~~~~~~~~
combo.cpp:61:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |         else if (r == S.length() + 1)
      |                  ~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...