# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
309005 | bigDuck | Password (RMI18_password) | C++14 | 501 ms | 660 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;
for(int i=s1.length(); i<(n); i++){
s1.pb(it->sc);
}
for(int i=res.length();(i>=0 && (res.length()<n));i--){
s1[i]=it->sc;
int ln=query(s1);
sum[i]=(ln-(i) );
}
s1.clear();
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);
}*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |