답안 #773221

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
773221 2023-07-04T17:00:18 Z TheSahib Password (RMI18_password) C++14
50 / 100
436 ms 452 KB
#include <bits/stdc++.h>

#define ll long long
#define pii pair<int, int>

using namespace std;

int cnt[30];

int query(string s);

string guess(int n, int s){
    for (char c = 'a'; c < 'a' + s; c++)
    {
        string a;
        for (int i = 0; i < n; i++)
        {
            a += c;
        }
        int b = query(a);
        cnt[c - 'a'] = b;
    }
    string ans = "";
    char c = 'a';
    for (; c < 'a' + s; c++)
    {
        if(cnt[c - 'a'] == 0) continue;
        while(cnt[c - 'a']--){
            ans += c;
        }
        c += 1;
        break;
    }
    
    for(; c < 'a' + s; c++){
        for(int i = 0; i <= ans.size() && cnt[c - 'a']; ++i){
            string z = ans;
            z.insert(z.begin() + i, c);
            int b = query(z);
            if(b == z.size()){
                ans = z;
                cnt[c - 'a']--;
            }
        }
    }
    return ans;
}

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:36:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         for(int i = 0; i <= ans.size() && cnt[c - 'a']; ++i){
      |                        ~~^~~~~~~~~~~~~
password.cpp:40:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |             if(b == z.size()){
      |                ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Guessed the password with 76 queries.
2 Correct 2 ms 208 KB Guessed the password with 187 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Guessed the password with 48 queries.
2 Correct 1 ms 208 KB Guessed the password with 116 queries.
3 Correct 1 ms 208 KB Guessed the password with 93 queries.
4 Correct 2 ms 208 KB Guessed the password with 221 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 304 KB Guessed the password with 4580 queries.
2 Correct 73 ms 316 KB Guessed the password with 10213 queries.
3 Correct 95 ms 320 KB Guessed the password with 12520 queries.
4 Correct 155 ms 328 KB Guessed the password with 20417 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Guessed the password with 76 queries.
2 Correct 2 ms 208 KB Guessed the password with 187 queries.
3 Correct 1 ms 208 KB Guessed the password with 48 queries.
4 Correct 1 ms 208 KB Guessed the password with 116 queries.
5 Correct 1 ms 208 KB Guessed the password with 93 queries.
6 Correct 2 ms 208 KB Guessed the password with 221 queries.
7 Correct 30 ms 304 KB Guessed the password with 4580 queries.
8 Correct 73 ms 316 KB Guessed the password with 10213 queries.
9 Correct 95 ms 320 KB Guessed the password with 12520 queries.
10 Correct 155 ms 328 KB Guessed the password with 20417 queries.
11 Correct 436 ms 316 KB Guessed the password with 49512 queries.
12 Correct 84 ms 328 KB Guessed the password with 11399 queries.
13 Correct 402 ms 336 KB Guessed the password with 47683 queries.
14 Correct 189 ms 452 KB Guessed the password with 21361 queries.
15 Correct 396 ms 336 KB Guessed the password with 44836 queries.
16 Correct 159 ms 324 KB Guessed the password with 17948 queries.
17 Correct 427 ms 312 KB Guessed the password with 49794 queries.
18 Correct 145 ms 428 KB Guessed the password with 14856 queries.
19 Incorrect 314 ms 304 KB Could not guess the password with 50000 queries.
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Guessed the password with 76 queries.
2 Correct 2 ms 208 KB Guessed the password with 187 queries.
3 Correct 1 ms 208 KB Guessed the password with 48 queries.
4 Correct 1 ms 208 KB Guessed the password with 116 queries.
5 Correct 1 ms 208 KB Guessed the password with 93 queries.
6 Correct 2 ms 208 KB Guessed the password with 221 queries.
7 Correct 30 ms 304 KB Guessed the password with 4580 queries.
8 Correct 73 ms 316 KB Guessed the password with 10213 queries.
9 Correct 95 ms 320 KB Guessed the password with 12520 queries.
10 Correct 155 ms 328 KB Guessed the password with 20417 queries.
11 Correct 436 ms 316 KB Guessed the password with 49512 queries.
12 Correct 84 ms 328 KB Guessed the password with 11399 queries.
13 Correct 402 ms 336 KB Guessed the password with 47683 queries.
14 Correct 189 ms 452 KB Guessed the password with 21361 queries.
15 Correct 396 ms 336 KB Guessed the password with 44836 queries.
16 Correct 159 ms 324 KB Guessed the password with 17948 queries.
17 Correct 427 ms 312 KB Guessed the password with 49794 queries.
18 Correct 145 ms 428 KB Guessed the password with 14856 queries.
19 Incorrect 314 ms 304 KB Could not guess the password with 50000 queries.
20 Halted 0 ms 0 KB -