Submission #464086

# Submission time Handle Problem Language Result Execution time Memory
464086 2021-08-12T11:00:49 Z Mamedov Password (RMI18_password) C++17
30 / 100
374 ms 276 KB
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define ll long long
#define ui unsigned int
#define pii pair<int, int>
#define piii pair<int, pii>
#define pb push_back
#define f first
#define s second
#define oo (1ll << 60)

using namespace std;


int query(string str);


string guess(int n, int s) {
    string str;
    vector<int>countLetter(s);
    int maxLetter = 0;
    for(int i = 0; i < s; ++i) {
        str = "";
        for(int j = 0; j < n; ++j) {
            str += ('a' + i);
        }
        countLetter[i] = query(str);
        if(countLetter[i] > countLetter[maxLetter]) {
            maxLetter = i;
        }
    }
    str = "";
    for(int i = 0; i < countLetter[maxLetter]; ++i) {
        str += ('a' + maxLetter);
    }
    for(int i = 0; i < s; ++i) {
        if(i == maxLetter) continue;
        for(int j = 0; j < countLetter[i]; ++j) {
            for(int k = 0; k <= str.length(); ++k) {
                str.insert(str.begin() + k, 'a' + i);
                if(query(str) == str.length()) {
                    break;
                }
                str.erase(str.begin() + k);
            }
        }
    }
    return str;
}

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:39:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |             for(int k = 0; k <= str.length(); ++k) {
      |                            ~~^~~~~~~~~~~~~~~
password.cpp:41:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |                 if(query(str) == str.length()) {
      |                    ~~~~~~~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Guessed the password with 76 queries.
2 Correct 3 ms 200 KB Guessed the password with 187 queries.
# Verdict Execution time Memory Grader output
1 Correct 12 ms 200 KB Guessed the password with 759 queries.
2 Correct 10 ms 200 KB Guessed the password with 716 queries.
3 Correct 14 ms 200 KB Guessed the password with 971 queries.
4 Correct 26 ms 200 KB Guessed the password with 2092 queries.
# Verdict Execution time Memory Grader output
1 Incorrect 374 ms 276 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 200 KB Guessed the password with 76 queries.
2 Correct 3 ms 200 KB Guessed the password with 187 queries.
3 Correct 12 ms 200 KB Guessed the password with 759 queries.
4 Correct 10 ms 200 KB Guessed the password with 716 queries.
5 Correct 14 ms 200 KB Guessed the password with 971 queries.
6 Correct 26 ms 200 KB Guessed the password with 2092 queries.
7 Incorrect 374 ms 276 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 200 KB Guessed the password with 76 queries.
2 Correct 3 ms 200 KB Guessed the password with 187 queries.
3 Correct 12 ms 200 KB Guessed the password with 759 queries.
4 Correct 10 ms 200 KB Guessed the password with 716 queries.
5 Correct 14 ms 200 KB Guessed the password with 971 queries.
6 Correct 26 ms 200 KB Guessed the password with 2092 queries.
7 Incorrect 374 ms 276 KB Could not guess the password with 50000 queries.
8 Halted 0 ms 0 KB -