# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
309000 | bigDuck | 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>
using namespace std;
#define INIT ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
/*int query(string str);
int query(string str){
cout<<str<<"\n"<<flush; int res; cin>>res; return res;
}*/
string guess(int n, int s){
set<pair<int, char>> ord;
for(char c='a'; c<=('a'+s-1); c++){
string st="";
for(int i=0; i<n; i++){st.pb(c);}
int ln=query(st);
if(ln==0){continue;}
ord.insert(mp(ln, c));
}
string res="";
for(int i=0; i<((ord.begin())->ft); i++){
res.pb((ord.begin())->sc);
}
ord.erase(ord.begin());
while(!ord.empty()){
auto it=ord.begin();
vector<int> sum; sum.assign(n+5, 0);
string s1=res; s1+="a";
string s2="";
for(int i=s1.length(); i<n; i++){
s2.pb(it->sc);
}s2.erase(s2.end()-1, s2.end());
for(;!s1.empty();){
s1.erase(s1.end()-1, s1.end());
s2.pb(it->sc);
int ln=query(s1+s2);
sum[s1.length()]=(ln-((int)s1.length()) );
}
int cnt=0;
for(int i=res.length(); i>=0; i--){
if(i<(res.length())){
s1="a"+s1; s1[0]=res[i];
}
while(cnt<sum[i]){
string st="a"; st[0]=(it->sc);
s1=st+s1; cnt++;
}
}
res=s1;
ord.erase(it);
}
return res;
}
/*int main(){
cout<<guess(6, 26);
}*/