Submission #1116319

# Submission time Handle Problem Language Result Execution time Memory
1116319 2024-11-21T13:52:58 Z Bula Password (RMI18_password) C++17
10 / 100
173 ms 692 KB
#include<bits/stdc++.h>
using namespace std;
int query(string p);
string guess(int n, int s){
    string t;
    for(char c = 'a'; c <= 'a' + s - 1; c++){
        string p;
        for(int i = 0; i < n; i++) p += c;
        int x = query(p);
        for(int i = 0; i < x; i++){
            int l = 0, r = t.size();
            while(l < r){
                int m = (l + r + 1) / 2;
                p.clear();
                for(int j = 0; j < m; j++) p += t[j];
                p += c;
                if(query(p) == m + 1) l = m;
                else r = m - 1;
            }
            p.clear();
            for(int j = 0; j < l; j++) p += t[j];
            p += c;
            for(int j = l; j < t.size(); j++) p += t[j];
            t = p;
        }
    }
    return t;
}

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:23:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |             for(int j = l; j < t.size(); j++) p += t[j];
      |                            ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 336 KB Guessed the password with 58 queries.
2 Correct 2 ms 504 KB Guessed the password with 100 queries.
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 336 KB Returned early from guess() after 228 queries.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 173 ms 692 KB Returned early from guess() after 8587 queries.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 336 KB Guessed the password with 58 queries.
2 Correct 2 ms 504 KB Guessed the password with 100 queries.
3 Incorrect 4 ms 336 KB Returned early from guess() after 228 queries.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 336 KB Guessed the password with 58 queries.
2 Correct 2 ms 504 KB Guessed the password with 100 queries.
3 Incorrect 4 ms 336 KB Returned early from guess() after 228 queries.
4 Halted 0 ms 0 KB -