Submission #866644

#TimeUsernameProblemLanguageResultExecution timeMemory
866644sofija6Password (RMI18_password)C++14
0 / 100
1 ms436 KiB
#include <bits/stdc++.h> using namespace std; int query(string q); string guess(int n, int s) { string ans=""; int cnt[26]={0}; for (int i=0;i<s;i++) { int l=1,r=n,mid; while (l<=r) { mid=(l+r)/2; string S=""; for (int j=1;j<=mid;j++) S+=(char)('a'+i); if (query(S)==mid) { cnt[i]=mid; l=mid+1; } else r=mid-1; } } for (int i=1;i<=n;i++) { int l=0,r=25,mid,lastt=-1; while (l<=r) { mid=(l+r)/2; string S=ans; for (int j=0;j<=mid;j++) { if (cnt[j]) S+=(char)(j+'a'); } if (S.empty()) l=mid+1; else if (query(S)>i-1) { lastt=mid; r=mid-1; } else l=mid+1; } ans+=(char)(lastt+'a'); cnt[lastt]--; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...