답안 #645898

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
645898 2022-09-28T09:01:19 Z Denkata Password (RMI18_password) C++17
20 / 100
54 ms 448 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;
pair <int,char> cnt[30];
string guess(int n,int s)
{
    sz=0;
    ///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);
        sz++;
        cnt[sz]={query(f),c};
    }
    sort(cnt+1,cnt+sz+1);
    for(i=1;i<=cnt[sz].first;i++)
        ans.push_back(cnt[sz].second);
    for(i=sz-1;i>=1;i--)
    {
        //cout<<ans<<" ans in the beginning"<<endl;
        if(cnt[i].first==0)break;
        int tek=ans.size();
        string newans="";
        string l="",r=ans;
        l.push_back(ans[0]);
        r.erase(0,1);
       // cout<<l<<" nachalni "<<r<<endl;
        j=0;
        int still=cnt[i].first;
        while(j<tek)
        {
            string f=l;
            for(int g=1;g<=still;g++)
                f.push_back(cnt[i].second);
            f=f+r;
           // cout<<f<<" for a query"<<endl;
            p=query(f);
            k=p-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]);
            j++;
            if(j<tek)
            {
                l.push_back(ans[j]);
                r.erase(0,1);
            }
        }
        for(int g=1;g<=still;g++)
            newans.push_back(cnt[i].second);
        ans=newans;
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Guessed the password with 29 queries.
2 Correct 1 ms 208 KB Guessed the password with 116 queries.
3 Correct 2 ms 208 KB Guessed the password with 169 queries.
4 Correct 2 ms 208 KB Guessed the password with 220 queries.
# 결과 실행 시간 메모리 Grader output
1 Runtime error 54 ms 448 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -