답안 #475327

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
475327 2021-09-21T20:46:58 Z ogibogi2004 Password (RMI18_password) C++14
0 / 100
51 ms 516 KB
#include<bits/stdc++.h>
using namespace std;
int query(string s);
string s1,s2,tmp;
int n1;
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;
            tmp.insert(tmp.begin()+i,s2[j]);
            if(query(tmp)==tmp.size())
            {
                s1=tmp;
                j++;
            }
        }
    }
    while(j<s2.size())s1+=s2[j++];
    //if(j<s2.size())assert(false);
    //if(s1.size()==n1)assert(false);
    return s1;
}
string guess(int n,int s)
{
    n1=n;
    string f=solve(0,s-1);
    if(f.size()!=n)assert(false);
    return f;
}

Compilation message

password.cpp: In function 'std::string solve(int, int)':
password.cpp:14:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |             if(query(s)!=s.size())
      |                ~~~~~~~~^~~~~~~~~~
password.cpp:26:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i=0;i<=s1.size();i++)
      |                 ~^~~~~~~~~~~
password.cpp:28:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         if(j<s2.size())
      |            ~^~~~~~~~~~
password.cpp:32:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |             if(query(tmp)==tmp.size())
      |                ~~~~~~~~~~^~~~~~~~~~~~
password.cpp:39:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     while(j<s2.size())s1+=s2[j++];
      |           ~^~~~~~~~~~
password.cpp: In function 'std::string guess(int, int)':
password.cpp:48:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |     if(f.size()!=n)assert(false);
      |        ~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 516 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Guessed the password with 98 queries.
2 Correct 2 ms 200 KB Guessed the password with 186 queries.
3 Correct 2 ms 200 KB Guessed the password with 183 queries.
4 Runtime error 2 ms 416 KB Execution killed with signal 6
# 결과 실행 시간 메모리 Grader output
1 Runtime error 51 ms 412 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 516 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 516 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -