답안 #773209

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
773209 2023-07-04T16:48:25 Z TheSahib Password (RMI18_password) C++14
30 / 100
342 ms 332 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() && cnt[c - 'a']; ++i){
                string z = ans;
                z.insert(z.begin() + i, c);
                int b = query(z);
                if(b == z.size()){
                    ans = z;
                    i += 1;
                    cnt[c - 'a']--;
                }
            }
        }
    }
    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() && cnt[c - 'a']; ++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 1 ms 256 KB Guessed the password with 187 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Guessed the password with 80 queries.
2 Correct 1 ms 208 KB Guessed the password with 161 queries.
3 Correct 2 ms 208 KB Guessed the password with 175 queries.
4 Correct 5 ms 208 KB Guessed the password with 394 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 101 ms 312 KB Guessed the password with 11857 queries.
2 Correct 303 ms 332 KB Guessed the password with 37122 queries.
3 Correct 149 ms 316 KB Guessed the password with 21280 queries.
4 Incorrect 342 ms 324 KB Could not guess the password with 50000 queries.
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Guessed the password with 76 queries.
2 Correct 1 ms 256 KB Guessed the password with 187 queries.
3 Correct 1 ms 208 KB Guessed the password with 80 queries.
4 Correct 1 ms 208 KB Guessed the password with 161 queries.
5 Correct 2 ms 208 KB Guessed the password with 175 queries.
6 Correct 5 ms 208 KB Guessed the password with 394 queries.
7 Correct 101 ms 312 KB Guessed the password with 11857 queries.
8 Correct 303 ms 332 KB Guessed the password with 37122 queries.
9 Correct 149 ms 316 KB Guessed the password with 21280 queries.
10 Incorrect 342 ms 324 KB Could not guess the password with 50000 queries.
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Guessed the password with 76 queries.
2 Correct 1 ms 256 KB Guessed the password with 187 queries.
3 Correct 1 ms 208 KB Guessed the password with 80 queries.
4 Correct 1 ms 208 KB Guessed the password with 161 queries.
5 Correct 2 ms 208 KB Guessed the password with 175 queries.
6 Correct 5 ms 208 KB Guessed the password with 394 queries.
7 Correct 101 ms 312 KB Guessed the password with 11857 queries.
8 Correct 303 ms 332 KB Guessed the password with 37122 queries.
9 Correct 149 ms 316 KB Guessed the password with 21280 queries.
10 Incorrect 342 ms 324 KB Could not guess the password with 50000 queries.
11 Halted 0 ms 0 KB -