Submission #475316

# Submission time Handle Problem Language Result Execution time Memory
475316 2021-09-21T20:29:47 Z ogibogi2004 Password (RMI18_password) C++14
0 / 100
29 ms 320 KB
#include<bits/stdc++.h>
using namespace std;
int query(string s);
string s1,s2,tmp;
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;
    s1=solve(l,mid);
    s2=solve(mid+1,r);
    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:13:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |             if(query(s)!=s.size())
      |                ~~~~~~~~^~~~~~~~~~
password.cpp:25:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(int i=0;i<=s1.size();i++)
      |                 ~^~~~~~~~~~~
password.cpp:27:13: 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(j<s2.size())
      |            ~^~~~~~~~~~
password.cpp:30:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             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 2 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 29 ms 320 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 -