Submission #755899

# Submission time Handle Problem Language Result Execution time Memory
755899 2023-06-10T17:30:24 Z vjudge1 Password (RMI18_password) C++17
30 / 100
629 ms 288 KB
#include <bits/stdc++.h>
 
        using namespace std;
 
        string st; int k;
        int query(string str);
 
        string guess(int n, int s) {
            string S(n, 'a');
            int freq[s]{0};
            for(int l = 0; l < s; l++) {
                for(int i = 0; i < n; i++)
                    S[i] = char('a' + l);
                freq[l] = query(S);
            }
            S = "";
            for(int l = 0; l < s; l++) {
                for(int i = 0, last = 0; i < freq[l]; i++) {
                    for(int j = last;; j++) {
                        string str = "";
                        for(int e = 0; e < j; e++) str.push_back(S[e]);
                        str.push_back(char('a' + l));
                        for(int e = j; e < S.size(); e++)
                            str.push_back(S[e]);
                        if(query(str) == str.size()) {
                            S = str; last++; break;
                        }
                    }
                }
            }
            return S;
        }

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:23:42: 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 e = j; e < S.size(); e++)
      |                                        ~~^~~~~~~~~~
password.cpp:25:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |                         if(query(str) == str.size()) {
      |                            ~~~~~~~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Guessed the password with 77 queries.
2 Correct 4 ms 208 KB Guessed the password with 188 queries.
# Verdict Execution time Memory Grader output
1 Correct 2 ms 208 KB Guessed the password with 161 queries.
2 Correct 8 ms 208 KB Guessed the password with 629 queries.
3 Correct 2 ms 208 KB Guessed the password with 112 queries.
4 Correct 19 ms 208 KB Guessed the password with 1469 queries.
# Verdict Execution time Memory Grader output
1 Incorrect 629 ms 288 KB Could not guess the password with 50000 queries.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Guessed the password with 77 queries.
2 Correct 4 ms 208 KB Guessed the password with 188 queries.
3 Correct 2 ms 208 KB Guessed the password with 161 queries.
4 Correct 8 ms 208 KB Guessed the password with 629 queries.
5 Correct 2 ms 208 KB Guessed the password with 112 queries.
6 Correct 19 ms 208 KB Guessed the password with 1469 queries.
7 Incorrect 629 ms 288 KB Could not guess the password with 50000 queries.
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Guessed the password with 77 queries.
2 Correct 4 ms 208 KB Guessed the password with 188 queries.
3 Correct 2 ms 208 KB Guessed the password with 161 queries.
4 Correct 8 ms 208 KB Guessed the password with 629 queries.
5 Correct 2 ms 208 KB Guessed the password with 112 queries.
6 Correct 19 ms 208 KB Guessed the password with 1469 queries.
7 Incorrect 629 ms 288 KB Could not guess the password with 50000 queries.
8 Halted 0 ms 0 KB -