# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1069971 | AdamGS | Password (RMI18_password) | C++17 | 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>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
string guess(int n, int s) {
vector<pair<int,string>>A;
rep(i, s) {
string p="";
rep(j, n) p+=char(i+'a');
int x=query(p);
while(p.size()>x) p.pop_back();
if(x) A.pb({x, p});
}
while(A.size()>1) {
sort(all(A));
reverse(all(A));
string a=A[A.size()-1].nd, b=A[A.size()-2].nd;
A.pop_back(); A.pop_back();
int l=0;
string ans="";
for(auto i : a) {
string x=ans;
x+=i;
for(int j=l; j<b.size(); ++j) x+=b[j];
while(query(x)<x.size()) {
ans+=b[l];
++l;
x=ans;
x+=i;
for(int j=l; j<b.size(); ++j) x+=b[j];
}
ans+=i;
}
A.pb({ans.size(), ans});
}
return A[0].nd;
}