Submission #709737

#TimeUsernameProblemLanguageResultExecution timeMemory
709737siewjhPassword (RMI18_password)C++17
100 / 100
245 ms688 KiB
#include <bits/stdc++.h> using namespace std; int query(string q); string chain(char ch, int x){ string str = ""; for (int i = 0; i < x; i++) str += ch; return str; } string guess(int n, int s){ priority_queue<pair<int, string>> pq; for (int i = 0; i < s; i++){ char ch = 'a' + i; int amt = query(chain(ch, n)); pq.push({-amt, chain(ch, amt)}); } while (pq.size() >= 2){ string s1, s2; s1 = pq.top().second; pq.pop(); s2 = pq.top().second; pq.pop(); string mrg = ""; while (!s1.empty() && !s2.empty()){ if (query(mrg + s1[0] + s2) == mrg.size() + 1 + s2.size()){ mrg += s1[0]; s1.erase(0, 1); } else{ mrg += s2[0]; s2.erase(0, 1); } } if (!s1.empty()) mrg += s1; else mrg += s2; pq.push({-mrg.size(), mrg}); } return pq.top().second; }

Compilation message (stderr)

password.cpp: In function 'std::string guess(int, int)':
password.cpp:25:41: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |             if (query(mrg + s1[0] + s2) == mrg.size() + 1 + s2.size()){
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...