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;
using ll=long long;
using ld=long double;
using pii=pair<int,int>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()),c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll maxn=500+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e8+7;
const ld PI=acos(-1);
const ld eps=1e-4;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
int query(string s);
string merge(string a,string b){
int n=sz(a),m=sz(b);
int pa=0,pb=0;
string ans="";
while(pa<n and pb<m){
string cur=ans;
cur.pb(a[pa]);
for(int i=pb;i<m;i++) cur.pb(b[i]);
if(query(cur)==sz(cur)){
ans.pb(a[pa++]);
}
else ans.pb(b[pb++]);
}
while(pa<n) ans.pb(a[pa++]);
while(pb<m) ans.pb(b[pb++]);
return ans;
}
string guess(int n, int s){
set<pair<int,string>> ss;
REP(i,s){
string z="";
REP(a,n) z.pb(i+'a');
string ans="";
int k=query(z);
REP(a,k) ans.pb(i+'a');
ss.insert({k,ans});
}
while(sz(ss)>1){
auto a=(*ss.begin()).s;
ss.erase(ss.begin());
auto b=(*ss.begin()).s;
ss.erase(ss.begin());
string x=merge(a,b);
ss.insert({sz(x),x});
}
return (*ss.begin()).s;
}
# | 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... |