답안 #755903

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
755903 2023-06-10T17:33:07 Z MohamedFaresNebili Password (RMI18_password) C++14
50 / 100
1022 ms 340 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(;; 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:23:45: 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 = last; 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()) {
      |                            ~~~~~~~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Guessed the password with 77 queries.
2 Correct 3 ms 208 KB Guessed the password with 188 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Guessed the password with 72 queries.
2 Correct 2 ms 208 KB Guessed the password with 164 queries.
3 Correct 1 ms 208 KB Guessed the password with 103 queries.
4 Correct 3 ms 208 KB Guessed the password with 229 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 340 KB Guessed the password with 4581 queries.
2 Correct 165 ms 300 KB Guessed the password with 10303 queries.
3 Correct 151 ms 308 KB Guessed the password with 12561 queries.
4 Correct 336 ms 320 KB Guessed the password with 20501 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Guessed the password with 77 queries.
2 Correct 3 ms 208 KB Guessed the password with 188 queries.
3 Correct 1 ms 208 KB Guessed the password with 72 queries.
4 Correct 2 ms 208 KB Guessed the password with 164 queries.
5 Correct 1 ms 208 KB Guessed the password with 103 queries.
6 Correct 3 ms 208 KB Guessed the password with 229 queries.
7 Correct 55 ms 340 KB Guessed the password with 4581 queries.
8 Correct 165 ms 300 KB Guessed the password with 10303 queries.
9 Correct 151 ms 308 KB Guessed the password with 12561 queries.
10 Correct 336 ms 320 KB Guessed the password with 20501 queries.
11 Incorrect 1022 ms 320 KB Could not guess the password with 50000 queries.
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Guessed the password with 77 queries.
2 Correct 3 ms 208 KB Guessed the password with 188 queries.
3 Correct 1 ms 208 KB Guessed the password with 72 queries.
4 Correct 2 ms 208 KB Guessed the password with 164 queries.
5 Correct 1 ms 208 KB Guessed the password with 103 queries.
6 Correct 3 ms 208 KB Guessed the password with 229 queries.
7 Correct 55 ms 340 KB Guessed the password with 4581 queries.
8 Correct 165 ms 300 KB Guessed the password with 10303 queries.
9 Correct 151 ms 308 KB Guessed the password with 12561 queries.
10 Correct 336 ms 320 KB Guessed the password with 20501 queries.
11 Incorrect 1022 ms 320 KB Could not guess the password with 50000 queries.
12 Halted 0 ms 0 KB -