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;
int query(string q);
string guess(int n, int s){
vector<pair<int,char> >amt;
for(char i='a';i<='a'+s-1;i++){
string q="";
for(int j=1;j<=n;j++){
q+=i;
}
amt.push_back({query(q),i});
}
sort(amt.begin(),amt.end());
// for(pair<int,char>i:amt){
// cout<<i.first<<' '<<i.second<<endl;
// }
string ans="";
for(int i=1;i<=n;i++) ans+=amt.back().second;
set<pair<int,char> >rem;
for(pair<int,char>i:amt) rem.insert(i);
for(pair<int,char>i:amt){
rem.erase(i);
for(int num=i.first;num>=1;num--){
string pr="";
for(int k=1;k<=num;k++) pr+=i.second;
int raod=0;
for(pair<int,char> j:rem){
string qu=pr;
for(int k=1;k<=j.first;k++){
qu+=j.second;
}
raod+=query(qu)-num;
}
int cur=n-1;
if(ans[cur]!=amt.back().second) raod++;
while(raod){
cur--;
raod--;
if(ans[cur]!=amt.back().second) raod++;
}
ans[cur]=i.second;
}
}
return ans;
}
# | 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... |