Submission #475313

# Submission time Handle Problem Language Result Execution time Memory
475313 2021-09-21T20:25:02 Z ogibogi2004 Password (RMI18_password) C++14
0 / 100
26 ms 300 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(0,25);
}

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())
      |                ~~~~~~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 26 ms 300 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -