Submission #475312

# Submission time Handle Problem Language Result Execution time Memory
475312 2021-09-21T20:24:21 Z ogibogi2004 Password (RMI18_password) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
int query(string s);
string solve(int l,int r)
{
    if(l==r)
    {
        string s="";
        for(int j=0;;j++)
        {
            s+=char('a'+l);
            if(query(s)!=s.size())
            {
                s.pop_back();
                return s;
            }
        }
    }
    int mid=(l+r)/2;
    string s1=solve(l,mid);
    string s2=solve(mid+1,r);
    string tmp="";
    int j=0;
    for(int i=0;i<=s1.size();i++)
    {
        if(j<s2.size())
        {
            tmp=s1.substr(0,i)+s2[j]+s1.substr(i,s1.size()-i);
            if(query(tmp)==tmp.size())
            {
                s1=tmp;
                j++;
            }
        }
    }
    return s1;
}
string guess(int n,int s)
{
    return solve(l,r);
}

Compilation message

password.cpp: In function 'std::string solve(int, int)':
password.cpp:12:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |             if(query(s)!=s.size())
      |                ~~~~~~~~^~~~~~~~~~
password.cpp:24:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i=0;i<=s1.size();i++)
      |                 ~^~~~~~~~~~~
password.cpp:26:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         if(j<s2.size())
      |            ~^~~~~~~~~~
password.cpp:29:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |             if(query(tmp)==tmp.size())
      |                ~~~~~~~~~~^~~~~~~~~~~~
password.cpp: In function 'std::string guess(int, int)':
password.cpp:40:18: error: 'l' was not declared in this scope
   40 |     return solve(l,r);
      |                  ^
password.cpp:40:20: error: 'r' was not declared in this scope
   40 |     return solve(l,r);
      |                    ^