Submission #755955

# Submission time Handle Problem Language Result Execution time Memory
755955 2023-06-10T18:28:27 Z MohamedFaresNebili Password (RMI18_password) C++14
50 / 100
1104 ms 316 KB
#include <bits/stdc++.h>

        using namespace std;

        int query(string str);

        string guess(int n, int s) {
            string S(n, 'a');
            int freq[s]{0};
            vector<pair<int, int>> v;
            for(int l = 0; l < s; l++) {
                for(int i = 0; i < n; i++)
                    S[i] = char('a' + l);
                freq[l] = query(S);
                v.push_back({freq[l], l});
            }
            sort(v.begin(), v.end());
            reverse(v.begin(), v.end());
            S = "";
            for(int l = 0; l < v[0].first; l++)
                S += char('a' + v[0].second);
            for(int _ = 1; _ < s; _++) {
                int l = v[_].second;
                for(int i = 0, last = 0; i < freq[l]; i++) {
                    for(;; last++) {
                        string str = "";
                        for(int e = 0; e < last; e++) str.push_back(S[e]);
                        str.push_back(char('a' + l));
                        for(int e = last; 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:29:45: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |                         for(int e = last; e < S.size(); e++)
      |                                           ~~^~~~~~~~~~
password.cpp:31:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |                         if(query(str) == str.size()) {
      |                            ~~~~~~~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Guessed the password with 87 queries.
2 Correct 1 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 128 queries.
3 Correct 3 ms 208 KB Guessed the password with 181 queries.
4 Correct 3 ms 208 KB Guessed the password with 264 queries.
# Verdict Execution time Memory Grader output
1 Correct 121 ms 312 KB Guessed the password with 8257 queries.
2 Correct 139 ms 312 KB Guessed the password with 10639 queries.
3 Correct 280 ms 304 KB Guessed the password with 19403 queries.
4 Correct 455 ms 316 KB Guessed the password with 26461 queries.
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Guessed the password with 87 queries.
2 Correct 1 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 128 queries.
5 Correct 3 ms 208 KB Guessed the password with 181 queries.
6 Correct 3 ms 208 KB Guessed the password with 264 queries.
7 Correct 121 ms 312 KB Guessed the password with 8257 queries.
8 Correct 139 ms 312 KB Guessed the password with 10639 queries.
9 Correct 280 ms 304 KB Guessed the password with 19403 queries.
10 Correct 455 ms 316 KB Guessed the password with 26461 queries.
11 Incorrect 1104 ms 312 KB Could not guess the password with 50000 queries.
12 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 1 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 128 queries.
5 Correct 3 ms 208 KB Guessed the password with 181 queries.
6 Correct 3 ms 208 KB Guessed the password with 264 queries.
7 Correct 121 ms 312 KB Guessed the password with 8257 queries.
8 Correct 139 ms 312 KB Guessed the password with 10639 queries.
9 Correct 280 ms 304 KB Guessed the password with 19403 queries.
10 Correct 455 ms 316 KB Guessed the password with 26461 queries.
11 Incorrect 1104 ms 312 KB Could not guess the password with 50000 queries.
12 Halted 0 ms 0 KB -