# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
199689 | zoooma13 | 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.
#include <bits/stdc++.h>
#include "grader.cpp"
using namespace std;
string merge(string s ,string t){
for(int j=(int)s.size(),i=(int)t.size()-1; ~i; i--){
while(true){
string q = s;
q.insert(q.begin()+j ,t[i]);
if(query(q) == q.size()){
s = q;
break;
}
j--;
}
}
return s;
}
string guess(int n ,int s){
vector <string> vs;
for(int x,i=0; i<s; i++){
x = query(string(n ,'a'+i));
if(x)
vs.push_back(string(x ,'a'+i));
}
while(vs.size()>1){
sort(vs.begin() ,vs.end() ,[](string s ,string t){
return s.size() > t.size();
});
string x = vs.back(); vs.pop_back();
string y = vs.back(); vs.pop_back();
vs.push_back(merge(x ,y));
}
return vs.front();
}