Submission #848783

# Submission time Handle Problem Language Result Execution time Memory
848783 2023-09-13T13:40:10 Z TahirAliyev Password (RMI18_password) C++17
50 / 100
305 ms 1476 KB
#include <bits/stdc++.h>

using namespace std;

int query(string str);

vector<string> v;

string merge(string a, string b){
    int p1 = 0, p2 = 0;
    while(p1 <= a.size() && p2 < b.size()){
        string q = a;
        q.insert(q.begin() + p1, b[p2]);
        if(query(q) == q.size()){
            a = q;
            p2++;
        }
        else{
            p1++;
        }
    }
    return a;
}

string guess(int n, int s){
    for(char c = 'a'; c <= 'a' + s - 1; c++){
        string s = "";
        for(int i = 1; i <= n; i++){
            s += c;
        }
        int cnt = query(s);
        s = "";
        for(int i = 1; i <= cnt; i++){
            s += c;
        }
        v.push_back(s);
    }
    string main = v[0];
    for(int i = 1; i < v.size(); i++){
        main = merge(main, v[i]);
    }
    return main;
}

Compilation message

password.cpp: In function 'std::string merge(std::string, std::string)':
password.cpp:11:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     while(p1 <= a.size() && p2 < b.size()){
      |           ~~~^~~~~~~~~~~
password.cpp:11:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     while(p1 <= a.size() && p2 < b.size()){
      |                             ~~~^~~~~~~~~~
password.cpp:14:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |         if(query(q) == q.size()){
      |            ~~~~~~~~~^~~~~~~~~~~
password.cpp: In function 'std::string guess(int, int)':
password.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for(int i = 1; i < v.size(); i++){
      |                    ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 596 KB Guessed the password with 76 queries.
2 Correct 1 ms 436 KB Guessed the password with 187 queries.
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Guessed the password with 73 queries.
2 Correct 1 ms 344 KB Guessed the password with 135 queries.
3 Correct 1 ms 344 KB Guessed the password with 93 queries.
4 Correct 1 ms 432 KB Guessed the password with 306 queries.
# Verdict Execution time Memory Grader output
1 Correct 28 ms 956 KB Guessed the password with 5492 queries.
2 Correct 50 ms 1476 KB Guessed the password with 11382 queries.
3 Correct 70 ms 964 KB Guessed the password with 14049 queries.
4 Correct 109 ms 956 KB Guessed the password with 22311 queries.
# Verdict Execution time Memory Grader output
1 Correct 0 ms 596 KB Guessed the password with 76 queries.
2 Correct 1 ms 436 KB Guessed the password with 187 queries.
3 Correct 1 ms 344 KB Guessed the password with 73 queries.
4 Correct 1 ms 344 KB Guessed the password with 135 queries.
5 Correct 1 ms 344 KB Guessed the password with 93 queries.
6 Correct 1 ms 432 KB Guessed the password with 306 queries.
7 Correct 28 ms 956 KB Guessed the password with 5492 queries.
8 Correct 50 ms 1476 KB Guessed the password with 11382 queries.
9 Correct 70 ms 964 KB Guessed the password with 14049 queries.
10 Correct 109 ms 956 KB Guessed the password with 22311 queries.
11 Incorrect 305 ms 960 KB Could not guess the password with 50000 queries.
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 596 KB Guessed the password with 76 queries.
2 Correct 1 ms 436 KB Guessed the password with 187 queries.
3 Correct 1 ms 344 KB Guessed the password with 73 queries.
4 Correct 1 ms 344 KB Guessed the password with 135 queries.
5 Correct 1 ms 344 KB Guessed the password with 93 queries.
6 Correct 1 ms 432 KB Guessed the password with 306 queries.
7 Correct 28 ms 956 KB Guessed the password with 5492 queries.
8 Correct 50 ms 1476 KB Guessed the password with 11382 queries.
9 Correct 70 ms 964 KB Guessed the password with 14049 queries.
10 Correct 109 ms 956 KB Guessed the password with 22311 queries.
11 Incorrect 305 ms 960 KB Could not guess the password with 50000 queries.
12 Halted 0 ms 0 KB -