This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include "messy.h"
#define pb push_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxN = 1e3 + 5;
const int mod = 1e9 + 7;
const ll oo = 1e18;
vector<int> P;
vector<int> vc[maxN][maxN];
string s;
int n;
void Prepair(int l, int r)
{
if(l == r)
return;
int mid = (l + r) / 2;
for(int i=l; i<=r; i++)
s[i] = '0';
for(int i=l; i<=mid; i++)
{
s[i] = '1';
//cout << s << '\n';
add_element(s);
s[i] = '0';
}
for(int i=l; i<=r; i++)
s[i] = '1';
Prepair(l, mid);
Prepair(mid + 1, r);
}
void DnC(int l, int r)
{
//cout << s;exit(0);
if(l == r)
return;
int mid = (l + r) / 2;
for(int i=0; i<n; i++)
{
if(s[i] == '0')
{
//cout << s << '\n';
s[i] = '1';
if(check_element(s))
{
// cerr << s << "\n";
vc[l][mid].pb(i);
}
else
vc[mid + 1][r].pb(i);
s[i] = '0';
}
}
// cerr << vc[l][mid].size() << " " << vc[mid + 1][r].size() << '\n';
for(int i : vc[mid + 1][r])
s[i] = '1';
DnC(l, mid);
for(int i : vc[mid + 1][r])
s[i] = '0';
for(int i : vc[l][mid])
s[i] = '1';
DnC(mid + 1, r);
for(int i : vc[l][mid])
s[i] = '0';
}
vector<int> restore_permutation(int _n, int w, int r)
{
n = _n;
P.resize(n);
for(int i=0; i<n; i++)
vc[0][n - 1].pb(i);
for(int i=0; i<n; i++)
s += '1';
Prepair(0, n - 1);
compile_set();
for(int i=0; i<n; i++)
s[i] = '0';
DnC(0, n - 1);
// cout << vc[0][0].size();exit(0);
for(int i=0; i<n; i++)
{
//cout << i << " ";
P[vc[i][i][0]] = i;
}
return P;
}
/*void Solve()
{
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
ReadInput();
Solve();
}*/
# | 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... |