Submission #866636

# Submission time Handle Problem Language Result Execution time Memory
866636 2023-10-26T14:37:25 Z sofija6 Password (RMI18_password) C++14
0 / 100
1 ms 440 KB
#include <bits/stdc++.h>
 
using namespace std;
 
int query(string str);
 
string guess(int n, int s)
{
    string ans="";
    int cnt[26]={0};
    for (int i=0;i<26;i++)
    {
        int l=1,r=n,mid;
        while (l<=r)
        {
            mid=(l+r)/2;
            string s="";
            for (int j=1;j<=mid;j++)
                s+=(char)('a'+i);
            if (query(s)==mid)
            {
                cnt[i]=mid;
                l=mid+1;
            }
            else
                r=mid-1;
        }
    }
    for (int i=1;i<=n;i++)
    {
        int l=0,r=25,mid,lastt=-1;
        while (l<=r)
        {
            mid=(l+r)/2;
            string s=ans;
            for (int j=0;j<=mid;j++)
            {
                if (cnt[j])
                    s+=(char)(j+'a');
            }
            if (query(s)>(int)ans.size())
            {
                lastt=mid;
                r=mid-1;
            }
            else
                l=mid+1;
        }
        ans+=(char)(lastt+'a');
        cnt[lastt]--;
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 432 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 436 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 440 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 432 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 432 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -