Submission #1111192

# Submission time Handle Problem Language Result Execution time Memory
1111192 2024-11-11T16:50:09 Z sofija6 Password (RMI18_password) C++17
10 / 100
44 ms 584 KB
#include <bits/stdc++.h>
 
using namespace std;
 
int query(string str);
 
string Merge(string a,string b)
{
    int posa=0,posb=0;
    string ans="";
    while (posa<a.size() && posb<b.size())
    {
        string d="";
        d+=a[posa];
        for (int j=posb;j<b.size();j++)
            d+=(char)b[j];
        if (query(d)==(int)d.size())
        {
            ans+=a[posa];
            posa++;
        }
        else
        {
            ans+=b[posb];
            posb++;
        }
    }
    for (int i=posa;i<a.size();i++)
        ans+=a[i];
    for (int i=posb;i<b.size();i++)
        ans+=b[i];
    return ans;
}
bool Cmp(string a,string b)
{
    return a.size()<b.size();
}
string guess(int n, int s)
{
    vector<string> cur,cur1;
    for (int i=0;i<s;i++)
    {
        string ss="";
        for (int j=0;j<n;j++)
            ss+=(char)('a'+i);
        int len=query(ss);
        if (len)
        {
            ss="";
            for (int j=0;j<len;j++)
                ss+=(char)('a'+i);
            cur.push_back(ss);
        }
    }
    while (cur.size()!=1)
    {
        sort(cur.begin(),cur.end(),Cmp);
        string a=cur[0],b=cur[1];
        for (int i=2;i<cur.size();i++)
            cur1.push_back(cur[i]);
        cur=cur1;
        cur1.clear();
        cur.push_back(Merge(a,b));
    }
    return cur[0];
}

Compilation message

password.cpp: In function 'std::string Merge(std::string, std::string)':
password.cpp:11:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     while (posa<a.size() && posb<b.size())
      |            ~~~~^~~~~~~~~
password.cpp:11:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     while (posa<a.size() && posb<b.size())
      |                             ~~~~^~~~~~~~~
password.cpp:15:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |         for (int j=posb;j<b.size();j++)
      |                         ~^~~~~~~~~
password.cpp:28:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for (int i=posa;i<a.size();i++)
      |                     ~^~~~~~~~~
password.cpp:30:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for (int i=posb;i<b.size();i++)
      |                     ~^~~~~~~~~
password.cpp: In function 'std::string guess(int, int)':
password.cpp:59:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |         for (int i=2;i<cur.size();i++)
      |                      ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 336 KB Guessed the password with 58 queries.
2 Correct 2 ms 336 KB Guessed the password with 100 queries.
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Returned early from guess() after 32 queries.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 584 KB Returned early from guess() after 2394 queries.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 336 KB Guessed the password with 58 queries.
2 Correct 2 ms 336 KB Guessed the password with 100 queries.
3 Incorrect 1 ms 336 KB Returned early from guess() after 32 queries.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 336 KB Guessed the password with 58 queries.
2 Correct 2 ms 336 KB Guessed the password with 100 queries.
3 Incorrect 1 ms 336 KB Returned early from guess() after 32 queries.
4 Halted 0 ms 0 KB -