Submission #773324

# Submission time Handle Problem Language Result Execution time Memory
773324 2023-07-04T21:43:30 Z TheSahib Password (RMI18_password) C++14
50 / 100
373 ms 464 KB
#include <bits/stdc++.h>
 
#define ll long long
#define pii pair<int, int>
 
using namespace std;
 
int query(string s);

string merge(string s1, string s2){
    int p = 0;
    string ans = s1;
    string z = "";
    for (int i = 0; i <= ans.size() && p < s2.size(); i++)
    {
        z = ans;
        z.insert(z.begin() + i, s2[p]);
        int b = query(z);
        if(b == z.size()){
            ans = z;
            p++;
        }
    }
    return ans;
}
 
string guess(int n, int s){
    vector<string> ss;
    for (int c = 'a'; c < 'a' + s; c++)
    {
        string a;
        for (int i = 0; i < n; i++)
        {
            a += c;
        }
        int b = query(a);
        a.erase(a.begin() + b, a.end());
        if(a.empty()) continue;
        ss.push_back(a);
    }
    while(ss.size() != 1){
        sort(ss.begin(), ss.end());
        string a = merge(ss[ss.size() - 1], ss[ss.size() - 2]);
        ss.pop_back();
        ss.pop_back();
        ss.push_back(a);
    }
    
    return ss[0];
}

Compilation message

password.cpp: In function 'std::string merge(std::string, std::string)':
password.cpp:14:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for (int i = 0; i <= ans.size() && p < s2.size(); i++)
      |                     ~~^~~~~~~~~~~~~
password.cpp:14:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for (int i = 0; i <= ans.size() && p < s2.size(); i++)
      |                                        ~~^~~~~~~~~~~
password.cpp:19:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |         if(b == z.size()){
      |            ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Guessed the password with 87 queries.
2 Correct 2 ms 208 KB Guessed the password with 156 queries.
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Guessed the password with 52 queries.
2 Correct 1 ms 208 KB Guessed the password with 95 queries.
3 Correct 2 ms 208 KB Guessed the password with 171 queries.
4 Correct 2 ms 208 KB Guessed the password with 234 queries.
# Verdict Execution time Memory Grader output
1 Correct 57 ms 332 KB Guessed the password with 6874 queries.
2 Correct 63 ms 344 KB Guessed the password with 9576 queries.
3 Correct 98 ms 336 KB Guessed the password with 12364 queries.
4 Correct 113 ms 348 KB Guessed the password with 19851 queries.
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Guessed the password with 87 queries.
2 Correct 2 ms 208 KB Guessed the password with 156 queries.
3 Correct 1 ms 208 KB Guessed the password with 52 queries.
4 Correct 1 ms 208 KB Guessed the password with 95 queries.
5 Correct 2 ms 208 KB Guessed the password with 171 queries.
6 Correct 2 ms 208 KB Guessed the password with 234 queries.
7 Correct 57 ms 332 KB Guessed the password with 6874 queries.
8 Correct 63 ms 344 KB Guessed the password with 9576 queries.
9 Correct 98 ms 336 KB Guessed the password with 12364 queries.
10 Correct 113 ms 348 KB Guessed the password with 19851 queries.
11 Correct 90 ms 460 KB Guessed the password with 11691 queries.
12 Correct 306 ms 328 KB Guessed the password with 39891 queries.
13 Correct 126 ms 364 KB Guessed the password with 23175 queries.
14 Incorrect 373 ms 464 KB Could not guess the password with 50000 queries.
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Guessed the password with 87 queries.
2 Correct 2 ms 208 KB Guessed the password with 156 queries.
3 Correct 1 ms 208 KB Guessed the password with 52 queries.
4 Correct 1 ms 208 KB Guessed the password with 95 queries.
5 Correct 2 ms 208 KB Guessed the password with 171 queries.
6 Correct 2 ms 208 KB Guessed the password with 234 queries.
7 Correct 57 ms 332 KB Guessed the password with 6874 queries.
8 Correct 63 ms 344 KB Guessed the password with 9576 queries.
9 Correct 98 ms 336 KB Guessed the password with 12364 queries.
10 Correct 113 ms 348 KB Guessed the password with 19851 queries.
11 Correct 90 ms 460 KB Guessed the password with 11691 queries.
12 Correct 306 ms 328 KB Guessed the password with 39891 queries.
13 Correct 126 ms 364 KB Guessed the password with 23175 queries.
14 Incorrect 373 ms 464 KB Could not guess the password with 50000 queries.
15 Halted 0 ms 0 KB -