Submission #1117080

#TimeUsernameProblemLanguageResultExecution timeMemory
1117080BulaPassword (RMI18_password)C++17
100 / 100
504 ms1628 KiB
#include<bits/stdc++.h> using namespace std; int query(string p); string guess(int n, int s){ string t; set<pair<int, string>> st; for(char c = 'a'; c <= 'a' + s - 1; c++){ string p; for(int i = 0; i < n; i++) p += c; int x = query(p); if(x == 0) continue; p.clear(); for(int i = 0; i < x; i++) p += c; st.insert({p.size(), p}); } while(st.size() > 1){ pair<int, string> pr = *st.begin(); st.erase(st.begin()); string a = pr.second; pr = *st.begin(); st.erase(st.begin()); string b = pr.second, ans; while(a.size() > 0){ string p = ans; p += a[0]; p += b; if(query(p) == p.size()){ ans += a[0]; a.erase(a.begin()); }else{ ans += b[0]; b.erase(b.begin()); } } ans += b; st.insert({ans.size(), ans}); } pair<int, string> pr = *st.begin(); return pr.second; }

Compilation message (stderr)

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