# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
866641 | sofija6 | Password (RMI18_password) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// Sample grader for contestants' use.
//
// Usage: place your input data in the file password.in in the format
#include <bits/stdc++.h>
int query(string str);
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 (query(S)>i-1)
{
lastt=mid;
r=mid-1;
}
else
l=mid+1;
}
ans+=(char)(lastt+'a');
cnt[lastt]--;
}
return ans;
}