| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1301595 | liangjeremy | Password (RMI18_password) | C++20 | 0 ms | 0 KiB |
#include<bits/stdc++.h>
//#include<bits/extc++.h>
#define fi first
#define se second
#define int long long
using namespace std;
//using namespace __gnu_pbds;
using db=double;
using ll=int64_t;
using sll=__int128;
using lb=long double;
mt19937 rng(random_device{}());
int query(string s);
string guess(int n, int s){
priority_queue<pair<int,string>,vector<pair<int,string>>,greater<pair<int,string>>>pq;
for(int i=0; i<s; i++){
string cur="";
for(int j=0; j<n; j++)cur+=char('a'+i);
int len=query(cur); cur="";
for(int j=0; j<len; j++)cur+=char('a'+i);
pq.push({len,cur});
}
auto merge=[&](string s1, string s2){
string cur=s1; int idx=0;
for(char x:s2){
while(true){
string nwcur="";
for(int k=0; k<idx; k++)nwcur+=cur[k];
nwcur+=x;
for(int k=idx; k<(int)cur.size(); k++)nwcur+=cur[k];
if(query(nwcur)==nwcur.size()){
cur=nwcur; idx++; break;
}else idx++;
}
}
return cur;
};
while(pq.size()>1){
string s1=pq.top().se; pq.pop();
string s2=pq.top().se; pq.pop();
string s=merge(s1,s2); pq.push({s.size(),s});
}
return pq.top().se;
}
