Submission #646136

# Submission time Handle Problem Language Result Execution time Memory
646136 2022-09-28T18:34:23 Z Denkata Password (RMI18_password) C++14
40 / 100
106 ms 456 KB
#include<bits/stdc++.h>
//#include "grader.cpp"
using namespace std;
int i,j,p,d,m,k,sz;
int query(string q);
string ans;
vector <pair <int,char>> cnt;
string guess(int n,int s)
{
    ans="";
    ///pisheshe i<='z'
    for(char c='a';c<='z';c++)
    {
        if(c-'a'+1>s)break;
        string f="";
        for(i=1;i<=n;i++)
            f.push_back(c);
        p=query(f);
        if(p==0)continue;
        cnt.push_back({-p,c});
    }
    sort(cnt.begin(),cnt.end());
    sz=cnt.size()-1;
    for(i=1;i<=-cnt[sz].first;i++)
        ans.push_back(cnt[sz].second);
    string newans="";
    for(int i=sz-1;i>=0;i--)
    {
        //cout<<ans<<" ans in the beginning"<<endl;
        if(cnt[i].first==0)break;
        cnt[i].first=-cnt[i].first;
        int tek=ans.size();
        newans="";
        string l="",r=ans;
        // cout<<l<<" nachalni "<<r<<endl;
        int still=cnt[i].first;
        for(int j=0;j<tek;j++)
        {
            l.push_back(ans[j]);
            r.erase(0,1);
            string f=l;
            for(int g=1;g<=still;g++)
                f.push_back(cnt[i].second);
            if(!r.empty())
                f=f+r;
           // cout<<f<<" for a query"<<endl;
            p=query(f);
            k=p-(int)l.size();
            if(k<still)
            {
                for(int g=1;g<=still-k;g++)
                    newans.push_back(cnt[i].second);
                still=k;///stil-(stil-k)
            }
            newans.push_back(ans[j]);
        }
        for(int g=1;g<=still;g++)
            newans.push_back(cnt[i].second);
        ans="";
        ans=newans;
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Guessed the password with 27 queries.
2 Correct 1 ms 208 KB Guessed the password with 32 queries.
3 Correct 1 ms 208 KB Guessed the password with 18 queries.
4 Correct 1 ms 208 KB Guessed the password with 90 queries.
# Verdict Execution time Memory Grader output
1 Correct 20 ms 340 KB Guessed the password with 2149 queries.
2 Correct 97 ms 356 KB Guessed the password with 8435 queries.
3 Correct 27 ms 456 KB Guessed the password with 3621 queries.
4 Correct 106 ms 448 KB Guessed the password with 12042 queries.
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -