Submission #1117073

# Submission time Handle Problem Language Result Execution time Memory
1117073 2024-11-22T19:59:24 Z Bula Password (RMI18_password) C++17
0 / 100
30 ms 700 KB
#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());
        }
      }
      st.insert({ans.size(), ans});
    }
    pair<int, string> pr = *st.begin();
    return pr.second;
}

Compilation message

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 time Memory Grader output
1 Incorrect 1 ms 336 KB Returned early from guess() after 34 queries.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Guessed the password with 52 queries.
2 Correct 2 ms 336 KB Guessed the password with 92 queries.
3 Correct 3 ms 336 KB Guessed the password with 105 queries.
4 Incorrect 4 ms 336 KB Returned early from guess() after 175 queries.
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 700 KB Returned early from guess() after 1617 queries.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Returned early from guess() after 34 queries.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Returned early from guess() after 34 queries.
2 Halted 0 ms 0 KB -