# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
207072 | istlemin | 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 "grader.cpp"
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define rep(i, a, b) for(ll i = a; i < ll(b); ++i)
#define rrep(i, a, b) for(ll i = b-1; i >= ll(a); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
int query(string str);
string combine(string a, string b){
string ans = "";
//cout<<a<<" "<<b<<endl;
while(b.size()&&a.size()){
if(query(ans+b[0]+a)==sz(ans)+sz(a)+1){
ans += b[0];
b.erase(b.begin());
} else {
ans += a[0];
a.erase(a.begin());
}
}
ans+=b;
ans+=a;
//cout<<ans<<endl;
return ans;
}
string guess(int n, int s){
vector<string> v;
rep(i,0,s) {
v.push_back(string(query(string(n,'a'+i)),'a'+i));
//cout<<v.back()<<endl;
}
while(v.size()>=2){
vector<string> newV;
rep(i,0,v.size()/2) newV.push_back(combine(v[2*i],v[2*i+1]));
if(v.size()%2==1) newV.push_back(v.back());
v = newV;
}
return v[0];
}