답안 #773206

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
773206 2023-07-04T16:40:39 Z TheSahib Password (RMI18_password) C++14
30 / 100
349 ms 428 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 (int 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++){
        while(cnt[c - 'a']--){
            for(int i = 0; i <= ans.size(); ++i){
                string z = ans;
                z.insert(z.begin() + i, c);
                int b = query(z);
                if(b == z.size()){
                    ans = z;
                    break;
                }
            }
        }
    }
    return ans;
}

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:37:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |             for(int i = 0; i <= ans.size(); ++i){
      |                            ~~^~~~~~~~~~~~~
password.cpp:41:22: 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(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 4 ms 208 KB Guessed the password with 451 queries.
2 Correct 5 ms 208 KB Guessed the password with 716 queries.
3 Correct 1 ms 208 KB Guessed the password with 103 queries.
4 Correct 29 ms 208 KB Guessed the password with 2941 queries.
# 결과 실행 시간 메모리 Grader output
1 Incorrect 349 ms 428 KB Could not guess the password with 50000 queries.
2 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 4 ms 208 KB Guessed the password with 451 queries.
4 Correct 5 ms 208 KB Guessed the password with 716 queries.
5 Correct 1 ms 208 KB Guessed the password with 103 queries.
6 Correct 29 ms 208 KB Guessed the password with 2941 queries.
7 Incorrect 349 ms 428 KB Could not guess the password with 50000 queries.
8 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 4 ms 208 KB Guessed the password with 451 queries.
4 Correct 5 ms 208 KB Guessed the password with 716 queries.
5 Correct 1 ms 208 KB Guessed the password with 103 queries.
6 Correct 29 ms 208 KB Guessed the password with 2941 queries.
7 Incorrect 349 ms 428 KB Could not guess the password with 50000 queries.
8 Halted 0 ms 0 KB -