Submission #475311

# Submission time Handle Problem Language Result Execution time Memory
475311 2021-09-21T20:23:08 Z ogibogi2004 Password (RMI18_password) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
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:11:16: error: 'query' was not declared in this scope
   11 |             if(query(s)!=s.size())
      |                ^~~~~
password.cpp:23:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i=0;i<=s1.size();i++)
      |                 ~^~~~~~~~~~~
password.cpp:25:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         if(j<s2.size())
      |            ~^~~~~~~~~~
password.cpp:28:16: error: 'query' was not declared in this scope
   28 |             if(query(tmp)==tmp.size())
      |                ^~~~~
password.cpp: In function 'std::string guess(int, int)':
password.cpp:39:18: error: 'l' was not declared in this scope
   39 |     return solve(l,r);
      |                  ^
password.cpp:39:20: error: 'r' was not declared in this scope
   39 |     return solve(l,r);
      |                    ^