# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
260362 | dvdg6566 | Password (RMI18_password) | C++14 | 374 ms | 768 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (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... |