제출 #709621

#제출 시각아이디문제언어결과실행 시간메모리
709621salmonPassword (RMI18_password)C++14
100 / 100
283 ms732 KiB
#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);

}

컴파일 시 표준 에러 (stderr) 메시지

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()){
      |            ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...