# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
260362 | dvdg6566 | Password (RMI18_password) | C++14 | 374 ms | 768 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 5001;
int query(string str);
int occ[26];
string res="";
int cmp(int a,int b){
if(a==-1&&b==-1)return -1;
if(a==-1)return b;
if(b==-1)return a;
string cons=res;
cons+=(char)('a'+b);
for(int i=0;i<occ[a];++i)cons+=(char)('a'+a);
// cerr<<cons<<'\n';
if(query(cons) == cons.size())return b;
return a;
}
struct node{
int s,e,m,v;
node *l,*r;
node(int _s,int _e):s(_s),e(_e){
m=(s+e)/2;
v=-1;
if(s==e){
if(occ[s])v=s;
}else{
l=new node(s,m);
r=new node(m+1,e);
v=cmp(l->v,r->v);
}
}
void remove(int x){
if(s==e){
--occ[x];
if(!occ[x])v=-1;
else v=x;
return;
}
if(x<=m)l->remove(x);
else r->remove(x);
v=cmp(l->v,r->v);
// cerr<<s<<' '<<e<<' '<<v<<'\n';
}
}*root;
string guess(int N,int S){
for(int i=0;i<S;++i){
string q="";
while(1){
q+=(char)(i+'a');
int t=query(q);
if(t==q.size())continue;
else break;
}
q.pop_back();
occ[i]=q.size();
}
root=new node(0,25);
for(int i=0;i<N;++i){
res+=('a'+root->v);
root->remove(root->v);
// cerr<<"Answer "<<res<<'\n';
}
return res;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |