# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
309031 | bigDuck | Password (RMI18_password) | C++14 | 0 ms | 0 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.
string guess(int n, int s){
stack<string> stv;
for(char c='a'; c<=('a'+s-1); c++){
string st="";
for(int i=0; i<n; i++){st.pb(c);}
int ln=query(st);
if(ln==0){continue;}
if(ln>0){
string s="";
for(int i=0; i<ln; i++){
s.pb(c);
}
stv.push(s);
}
}
while(stv.size()>1){
stack<string> stv2;
while(stv.size()>1){
string s1=stv.top(); stv.pop(); string s2=stv.top(); stv.pop();
string s3="";
int j=0, i=0;
for(; i<s1.length() && j<s2.length(); i++){
bool v=false;
string s4=s3; s4.pb(s1[i]);
for(int k=j; k<s2.length(); k++){
s4.pb(s2[k]);
}
v=(query(s4)==(s4.length()));
if(v){
s3.pb(s1[i]);
}
else{
s3.pb(s2[j]); j++; i--;
}
}
while(i<s1.length()){
s3.pb(s1[i]); i++;
}
while(j<s2.length()){
s3.pb(s2[j]); j++;
}
stv2.push(s3);
}
while(!stv2.empty()){
stv.push(stv2.top()); stv2.pop();
}
}
return stv.top();
}
/*int main(){
cout<<guess(6, 26);
}*/