답안 #872947

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
872947 2023-11-14T07:06:08 Z vjudge1 Password (RMI18_password) C++17
30 / 100
52 ms 1224 KB
#include <bits/stdc++.h>
using namespace std;
int query(string q);
string guess(int n, int s) {
    queue < pair<int, string> > S;
    for(char c = 'a'; c < 'a'+s; c++) {
        string cur;
        for(int i = 0; i < n; i++) cur += c;
        int m = query(cur);
        if(m > 0) {
            cur = "";
            for(int i = 0; i < m; i++) {
                cur += c;
            }
            S.push({cur.size(), cur});
        }
    }
    while(S.size() > 1) {
        string a = S.front().second;
        S.pop();
        string b = S.front().second;
        S.pop();
        string ans = "";
        int j = 0;
        for(int i = 0; i <= a.size(); i++) {

            while(j < b.size()) {
                string cur = ans;
                cur += b[j];
                for(int k = i; k < a.size(); k++) {
                    cur += a[k];
                }
                if(query(cur) == cur.size()) {
                    ans+=b[j];
                    j++;
                    continue;
                }
                break;
            }
            if(i < a.size()) ans += a[i];
        }
        S.push({ans.size(), ans});
    }
    return S.front().second;
}

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:25:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         for(int i = 0; i <= a.size(); i++) {
      |                        ~~^~~~~~~~~~~
password.cpp:27:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |             while(j < b.size()) {
      |                   ~~^~~~~~~~~~
password.cpp:30:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |                 for(int k = i; k < a.size(); k++) {
      |                                ~~^~~~~~~~~~
password.cpp:33:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |                 if(query(cur) == cur.size()) {
      |                    ~~~~~~~~~~~^~~~~~~~~~~~~
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(i < a.size()) ans += a[i];
      |                ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Guessed the password with 62 queries.
2 Correct 1 ms 344 KB Guessed the password with 121 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Guessed the password with 48 queries.
2 Correct 1 ms 344 KB Guessed the password with 124 queries.
3 Runtime error 1 ms 440 KB Execution killed with signal 13
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 1224 KB Guessed the password with 3555 queries.
2 Correct 26 ms 696 KB Guessed the password with 5067 queries.
3 Correct 28 ms 964 KB Guessed the password with 6706 queries.
4 Correct 52 ms 968 KB Guessed the password with 8818 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Guessed the password with 62 queries.
2 Correct 1 ms 344 KB Guessed the password with 121 queries.
3 Correct 1 ms 344 KB Guessed the password with 48 queries.
4 Correct 1 ms 344 KB Guessed the password with 124 queries.
5 Runtime error 1 ms 440 KB Execution killed with signal 13
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Guessed the password with 62 queries.
2 Correct 1 ms 344 KB Guessed the password with 121 queries.
3 Correct 1 ms 344 KB Guessed the password with 48 queries.
4 Correct 1 ms 344 KB Guessed the password with 124 queries.
5 Runtime error 1 ms 440 KB Execution killed with signal 13
6 Halted 0 ms 0 KB -