# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
199692 | Osama_Alkhodairy | 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>
#include "grader.cpp"
using namespace std;
int query(string s);
string guess(int n, int c){
vector <int> f(c);
for(char i = 'a' ; i < 'a' + c ; i++){
f[i - 'a'] = query(string(n, i));
}
string ans;
for(char i = 'a' ; i < 'a' + c ; i++){
string cur = ans;
int e = ans.size();
for(int j = 0 ; j < f[i - 'a'] ; j++){
while(e >= 15 && query(ans.substr(0, e - 15) + string(j + 1, i)) != e - 15 + j + 1){
e -= 16;
}
int l = max(0, e - 15), r = e;
while(l <= r){
int mid = (l + r) / 2;
if(query(ans.substr(0, mid) + string(j + 1, i)) == mid + j + 1) l = mid + 1;
else r = mid - 1;
}
cur.insert(cur.begin() + r, i);
}
ans = cur;
}
return ans;
}