# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
331232 | Peti | 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 <iostream>
#include <vector>
using namespace std;
string guess(int n, int s){
vector<int> db(26, 0);
for(int i = 0; i < s; i++){
char c = (char)((int)'a' + i);
string q;
q.assign(n, c);
db[i] = query(q);
}
string pass;
pass.assign(db[0], 'a');
for(int i = 1; i < s; i++){
char c = (char)((int)('a' + i));
for(int j = 0; j < db[i]; j++){
int x = 0;
while(1){
string q = pass;
q.insert(q.begin() + x, c);
if(query(q) == (int)q.size()){
pass = q;
break;
}
x++;
}
}
}
return pass;
}