Submission #855655

#TimeUsernameProblemLanguageResultExecution timeMemory
855655uomoproteinaPassword (RMI18_password)C++14
0 / 100
0 ms440 KiB
#include <bits/stdc++.h> using namespace std; string str = ""; string ans = ""; int query(string s); bool add(string s) { int ret = query(s); return ret == str.size() + ans.size() + 1; } void solve(int N, int S) { cout << str + ans << "\n"; if (ans.size() + str.size() == N) return; bool found = false; for (int i = 0; i < S && !found; i++) { if (add(str + char(i + (int)('a')) + ans)) { str += char(i + (int)('a')); found = true; } } if (!found) { reverse(ans.begin(), ans.end()); ans += str.back(); reverse(ans.begin(), ans.end()); str.pop_back(); } else { solve(N, S); } } string guess(int n, int s) { while (ans.size() + str.size() < n) { solve(n, s); } return str + ans; }

Compilation message (stderr)

password.cpp: In function 'bool add(std::string)':
password.cpp:13:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     return ret == str.size() + ans.size() + 1;
      |            ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
password.cpp: In function 'void solve(int, int)':
password.cpp:19:33: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |     if (ans.size() + str.size() == N) return;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~^~~~
password.cpp: In function 'std::string guess(int, int)':
password.cpp:44:36: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |     while (ans.size() + str.size() < n)
      |            ~~~~~~~~~~~~~~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...