제출 #309034

#제출 시각아이디문제언어결과실행 시간메모리
309034bigDuckPassword (RMI18_password)C++14
100 / 100
405 ms588 KiB
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount



int query(string str);
/*int query(string str){
cout<<str<<"\n"<<flush; int res; cin>>res; return res;
}*/







string guess(int n, int s){
stack<string> stv;
for(char c='a'; c<=('a'+s-1); c++){
    string st="";
    for(int i=0; i<n; i++){st.pb(c);}
    int ln=query(st);
    if(ln==0){continue;}
    if(ln>0){
        string s="";
        for(int i=0; i<ln; i++){
            s.pb(c);
        }
        stv.push(s);
    }
}


while(stv.size()>1){
    stack<string> stv2;
    while(stv.size()>1){
        string s1=stv.top(); stv.pop(); string s2=stv.top(); stv.pop();
        string s3="";
        int j=0, i=0;
        for(; i<s1.length() && j<s2.length(); i++){
            bool v=false;
            string s4=s3; s4.pb(s1[i]);
            for(int k=j; k<s2.length(); k++){
                s4.pb(s2[k]);
            }
            v=(query(s4)==(s4.length()));
            if(v){
                s3.pb(s1[i]);
            }
            else{
                s3.pb(s2[j]); j++; i--;
            }
        }

        while(i<s1.length()){
            s3.pb(s1[i]); i++;
        }
        while(j<s2.length()){
            s3.pb(s2[j]); j++;
        }
        stv2.push(s3);
    }

    while(!stv2.empty()){
        stv.push(stv2.top()); stv2.pop();
    }
}




return stv.top();
}


/*int main(){
cout<<guess(6, 26);




}*/


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

password.cpp: In function 'std::string guess(int, int)':
password.cpp:48:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         for(; i<s1.length() && j<s2.length(); i++){
      |               ~^~~~~~~~~~~~
password.cpp:48:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         for(; i<s1.length() && j<s2.length(); i++){
      |                                ~^~~~~~~~~~~~
password.cpp:51:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |             for(int k=j; k<s2.length(); k++){
      |                          ~^~~~~~~~~~~~
password.cpp:54:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |             v=(query(s4)==(s4.length()));
      |                ~~~~~~~~~^~~~~~~~~~~~~~~
password.cpp:63:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |         while(i<s1.length()){
      |               ~^~~~~~~~~~~~
password.cpp:66:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |         while(j<s2.length()){
      |               ~^~~~~~~~~~~~
#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...