답안 #709621

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
709621 2023-03-14T03:18:43 Z salmon Password (RMI18_password) C++14
100 / 100
283 ms 732 KB
#include <bits/stdc++.h>
using namespace std;

int query(string str);

string p(int s, int e, int n){
    if(s == e){
        string aas = "";
        aas.push_back('a' + s);
        while(query(aas) == aas.size() && aas.size() != n + 1){
            aas.push_back('a' + s);
        }
        aas.pop_back();
        return aas;
    }

    string temp = p(s, (s + e)/2,n);
    string temp1 = p((s + e)/2 + 1, e,n);
    int it = 0;
    int it1 = 0;

    string frot = "";

    int b = temp1.size() + temp.size();

    for(int i = 0; i < b; i++){
        if(it1 == temp1.size()){
            frot.push_back(temp[0]);
            temp.erase(0,1);
            it++;
            continue;
        }
        frot.push_back(temp1[it1]);
        if(query(frot + temp) == (frot + temp).size()){
            it1++;
            continue;
        }
        else{
            frot.pop_back();
            frot.push_back(temp[0]);
            temp.erase(0,1);
            it++;
        }
    }

    return frot;
};

string guess(int n, int s){

    return p(0,s - 1,n);

}

Compilation message

password.cpp: In function 'std::string p(int, int, int)':
password.cpp:10:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |         while(query(aas) == aas.size() && aas.size() != n + 1){
      |               ~~~~~~~~~~~^~~~~~~~~~~~~
password.cpp:10:54: 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(query(aas) == aas.size() && aas.size() != n + 1){
      |                                           ~~~~~~~~~~~^~~~~~~~
password.cpp:27:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         if(it1 == temp1.size()){
      |            ~~~~^~~~~~~~~~~~~~~
password.cpp:34:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         if(query(frot + temp) == (frot + temp).size()){
      |            ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Guessed the password with 83 queries.
2 Correct 2 ms 208 KB Guessed the password with 134 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Guessed the password with 98 queries.
2 Correct 2 ms 208 KB Guessed the password with 186 queries.
3 Correct 2 ms 208 KB Guessed the password with 183 queries.
4 Correct 3 ms 304 KB Guessed the password with 303 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 304 KB Guessed the password with 4704 queries.
2 Correct 62 ms 424 KB Guessed the password with 6353 queries.
3 Correct 77 ms 352 KB Guessed the password with 8184 queries.
4 Correct 62 ms 364 KB Guessed the password with 10721 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Guessed the password with 83 queries.
2 Correct 2 ms 208 KB Guessed the password with 134 queries.
3 Correct 1 ms 208 KB Guessed the password with 98 queries.
4 Correct 2 ms 208 KB Guessed the password with 186 queries.
5 Correct 2 ms 208 KB Guessed the password with 183 queries.
6 Correct 3 ms 304 KB Guessed the password with 303 queries.
7 Correct 40 ms 304 KB Guessed the password with 4704 queries.
8 Correct 62 ms 424 KB Guessed the password with 6353 queries.
9 Correct 77 ms 352 KB Guessed the password with 8184 queries.
10 Correct 62 ms 364 KB Guessed the password with 10721 queries.
11 Correct 166 ms 480 KB Guessed the password with 16482 queries.
12 Correct 119 ms 372 KB Guessed the password with 15454 queries.
13 Correct 83 ms 484 KB Guessed the password with 17410 queries.
14 Correct 170 ms 308 KB Guessed the password with 16979 queries.
15 Correct 184 ms 412 KB Guessed the password with 18514 queries.
16 Correct 116 ms 488 KB Guessed the password with 17685 queries.
17 Correct 187 ms 444 KB Guessed the password with 19414 queries.
18 Correct 173 ms 496 KB Guessed the password with 18594 queries.
19 Correct 166 ms 432 KB Guessed the password with 19885 queries.
20 Correct 149 ms 616 KB Guessed the password with 18488 queries.
21 Correct 151 ms 432 KB Guessed the password with 20490 queries.
22 Correct 178 ms 600 KB Guessed the password with 19408 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Guessed the password with 83 queries.
2 Correct 2 ms 208 KB Guessed the password with 134 queries.
3 Correct 1 ms 208 KB Guessed the password with 98 queries.
4 Correct 2 ms 208 KB Guessed the password with 186 queries.
5 Correct 2 ms 208 KB Guessed the password with 183 queries.
6 Correct 3 ms 304 KB Guessed the password with 303 queries.
7 Correct 40 ms 304 KB Guessed the password with 4704 queries.
8 Correct 62 ms 424 KB Guessed the password with 6353 queries.
9 Correct 77 ms 352 KB Guessed the password with 8184 queries.
10 Correct 62 ms 364 KB Guessed the password with 10721 queries.
11 Correct 166 ms 480 KB Guessed the password with 16482 queries.
12 Correct 119 ms 372 KB Guessed the password with 15454 queries.
13 Correct 83 ms 484 KB Guessed the password with 17410 queries.
14 Correct 170 ms 308 KB Guessed the password with 16979 queries.
15 Correct 184 ms 412 KB Guessed the password with 18514 queries.
16 Correct 116 ms 488 KB Guessed the password with 17685 queries.
17 Correct 187 ms 444 KB Guessed the password with 19414 queries.
18 Correct 173 ms 496 KB Guessed the password with 18594 queries.
19 Correct 166 ms 432 KB Guessed the password with 19885 queries.
20 Correct 149 ms 616 KB Guessed the password with 18488 queries.
21 Correct 151 ms 432 KB Guessed the password with 20490 queries.
22 Correct 178 ms 600 KB Guessed the password with 19408 queries.
23 Correct 283 ms 512 KB Guessed the password with 28708 queries.
24 Correct 250 ms 620 KB Guessed the password with 27770 queries.
25 Correct 223 ms 700 KB Guessed the password with 28853 queries.
26 Correct 224 ms 732 KB Guessed the password with 28374 queries.
27 Correct 269 ms 600 KB Guessed the password with 28807 queries.
28 Correct 273 ms 640 KB Guessed the password with 28436 queries.
29 Correct 272 ms 640 KB Guessed the password with 28873 queries.
30 Correct 250 ms 680 KB Guessed the password with 28818 queries.