Submission #646323

#TimeUsernameProblemLanguageResultExecution timeMemory
646323Matteo_VerzPassword (RMI18_password)C++17
30 / 100
83 ms480 KiB
#include <bits/stdc++.h> #ifdef BLAT #include "debug/debug.hpp" #else #define debug(x...) #endif using namespace std; int query(string s); string mergeStrings(string &a, string &b) { string mergedSoFar, queryString; while (a.size() || b.size()) { if (!a.size()) { mergedSoFar += b; return mergedSoFar; } queryString = mergedSoFar + a[0] + b; int len = query(queryString); if (len == queryString.size()) { mergedSoFar.push_back(a[0]); a.erase(0, 1); } else { mergedSoFar.push_back(b[0]); b.erase(0, 1); } } return mergedSoFar; } struct Compare { bool operator()(const string &a, const string &b) { return a.size() > b.size(); } }; string guess(int n, int s) { string ask; priority_queue <string, vector <string>, Compare> pq; for (char ch = 'a'; ch - 'a' < s; ch++) { ask.clear(); for (int i = 0; i < n; i++) ask += ch; int len = query(ask); ask = ""; for (int i = 0; i < len; i++) ask += ch; pq.push(ask); } while (pq.size() > 1) { string a = pq.top(); pq.pop(); string b = pq.top(); pq.pop(); string c = mergeStrings(a, b); pq.push(c); } return pq.top(); }

Compilation message (stderr)

password.cpp: In function 'std::string mergeStrings(std::string&, std::string&)':
password.cpp:23:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         if (len == queryString.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...