이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int query(string str);
string tostr(int x, int cnt)
{
string cv = "";
for(int i=0;i<cnt;i++)
cv.push_back((char)('a'+x));
return cv;
}
pair<int,int> v[30];
string guess(int n, int s)
{
string aux;
for(int i=0;i<s;i++)
{
aux = tostr(i, n);
v[i]={query(aux), i};
}
sort(v,v+s);
string rez="";
for(int i=0;i<s;i++)
{
int cnt = v[i].first;
int x = v[i].second;
if(cnt==0)
continue;
if((int)rez.size()==0)
{
rez = tostr(x, cnt);
continue;
}
if((int)rez.size()==n)
break;
string newrez="";
int nr = query(rez + tostr(x, n - (int)rez.size())) - (int)rez.size();
newrez = newrez + tostr(x, nr);
int suff = nr;
for(int j=(int)rez.size()-1;j>=0;j--)
{
if((int)newrez.size()==n)
break;
int nr = (query(rez.substr(0,j) + tostr(x, n - (int)rez.size())) - j) - suff;
newrez = newrez + rez[j] + tostr(x, nr);
suff = nr + suff;
}
reverse(newrez.begin(),newrez.end());
rez = newrez;
}
return rez;
}
# | 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... |