이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "messy.h"
#include <bits/stdc++.h>
using namespace std;
string s;
vector<int> ans;
void genQuery(int st, int dr)
{
if(st == dr)
return;
int mij=(st+dr)/2;
for(int i=st; i<=mij; i++)
{
s[i]='1';
//cout<<s<<'\n';
add_element(s);
s[i]='0';
}
for(int i=mij+1; i<=dr; i++)
s[i]='1';
genQuery(st, mij);
for(int i=mij+1; i<=dr; i++)
s[i]='0';
for(int i=st; i<=mij; i++)
s[i]='1';
genQuery(mij+1, dr);
}
void genAns(int st, int dr, vector<int> v)
{
/*
cout<<st<<' '<<dr<<":\n";
for(int it : v)
cout<<it<<' ';
cout<<"\n\n";
*/
if(st == dr)
{
ans[st] = v[0];
return;
}
int mij=(st+dr)/2;
vector<int> vL, vR;
for(int it : v)
{
s[it]='1';
//cout<<"query "<<s<<' ';
if(check_element(s))
{
//cout<<"da\n";
vL.push_back(it);
}
else
{
//cout<<"nu\n";
vR.push_back(it);
}
s[it]='0';
}
//cout<<'\n';
for(int it : vR)
s[it]='1';
genAns(st, mij, vL);
for(int it : vR)
s[it]='0';
for(int it : vL)
s[it]='1';
genAns(mij+1, dr, vR);
}
vector<int> restore_permutation(int n, int w, int r)
{
s.resize(n);
ans.resize(n);
for(int i=0; i<n; i++)
s[i]='0';
genQuery(0, n-1);
compile_set();
for(int i=0; i<n; i++)
s[i]='0';
vector<int> aux;
for(int i=0;i<n;i++)
aux.push_back(i);
genAns(0, n-1, aux);
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... |