이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int query(string s);
string guess(int n, int s)
{
int comb[26][26] = {0};
int freq[26] = {0};
for(int i = 0; i < 26; i++)
{
int l = 0, r = n;
while(l <= r)
{
int mid = (l + r) / 2;
string x = "";
for(int j = 0; j < mid; j++)x += (char(i + 'a'));
int sz = x.size();
if(query(x) == sz)l = mid + 1;
else r = mid - 1;
}
freq[i] = l - 1;
}
string ans = "";
for(int i = 0; i < s; i++)
{
for(int j = 0; j < s; j++)
{
string x = "";
x.push_back(char(i +'a'));
int cnt = freq[j];
while(cnt--)x.push_back(char(j + 'a'));
comb[i][j] = x.size();
}
}
for(int ind = 0; ind < n; ind++)
{
for(int i = 0; i < 26; i++)
{
bool check = 1;
for(int j = 0; j < 26; j++)
{
if(comb[i][j] != freq[j] + 1)
{
check = 0;
break;
}
}
if(check)
{
ans += char(i + 'a');
freq[i]--;
break;
}
}
}
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... |