Submission #251362

#TimeUsernameProblemLanguageResultExecution timeMemory
251362shenxyPassword (RMI18_password)C++14
100 / 100
255 ms744 KiB
#include <algorithm> #include <string> using namespace std; int cnt[26]; int query(string str); string dnc(int s, int e) { if (s == e) { string ans = ""; for (int i = 0; i < cnt[s]; ++i) ans.push_back('a' + s); return ans; } string l = dnc(s, (s + e) / 2), r = dnc((s + e) / 2 + 1, e); int ptr = 0; for (char c: r) { string x = l; x.insert(ptr, 1, c); while (query(x) != x.length()) x = l, x.insert(++ptr, 1, c); l = x; ++ptr; } return l; } string guess(int N, int S) { for (int i = 0; i < S; ++i) { string Q = ""; for (int j = 0; j < N; ++j) Q.push_back('a' + i); cnt[i] = query(Q); } return dnc(0, S - 1); }

Compilation message (stderr)

password.cpp: In function 'std::__cxx11::string dnc(int, int)':
password.cpp:17:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while (query(x) != x.length()) x = l, x.insert(++ptr, 1, c);
          ~~~~~~~~~^~~~~~~~~~~~~
#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...