답안 #852989

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
852989 2023-09-23T09:57:51 Z allin27x Password (RMI18_password) C++17
0 / 100
91 ms 1208 KB
#include <bits/stdc++.h>
using namespace std;

int query(string str);

string guess(int n, int s){
    string res;
    vector<int> nc(s, 0);
    for (int i=0; i<s; i++) nc[i] = query(string(n,'a'+i));
    while (res.size()<n){
        string rev = res; reverse(rev.begin(), rev.end());
        int mx = -1; for (int i=0; i<s; i++) if (nc[i]) {mx = i; break;}
        for (int i=mx+1; i<s; i++){
            if (query(string(nc[i], 'a'+i) + string(1,'a'+mx) + rev) != nc[i] + 1 + res.size()) mx = i;
        }
        nc[mx] --; res += 'a' + mx;
    }
    return res;
}
//aabcba

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:10:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   10 |     while (res.size()<n){
      |            ~~~~~~~~~~^~
password.cpp:14:70: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |             if (query(string(nc[i], 'a'+i) + string(1,'a'+mx) + rev) != nc[i] + 1 + res.size()) mx = i;
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 440 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Guessed the password with 47 queries.
2 Runtime error 1 ms 440 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 67 ms 1208 KB Guessed the password with 9988 queries.
2 Runtime error 91 ms 964 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 440 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 440 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -