This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include "messy.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%I64d", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%I64d\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e6 + 5;
const double eps = 1e-9;
int ans[MAXN];
void add(int l, int r, int n) {
if (l == r)
return;
string qr;
for (int i = 0; i < l; i++) qr.pb('1');
for (int i = l; i <= r; i++) qr.pb('0');
for (int i = r + 1; i < n; i++) qr.pb('1');
int m = (l + r) / 2;
for (int i = l; i <= m; i++) {
qr[i] = '1';
add_element(qr);
qr[i] = '0';
}
add(l, m, n);
add(m + 1, r, n);
}
void check(int l, int r, int n, vi ind) {
if (l == r) {
ans[ind[0]] = l;
return;
}
int m = (l + r) / 2;
string qr;
for (int i = 0; i < n; i++) qr.pb('1');
for (int i = 0; i < ind.size(); i++) qr[ind[i]] = '0';
vi indL, indR;
for (int i = 0; i < ind.size(); i++) {
qr[ind[i]] = '1';
bool fl = check_element(qr);
if (fl)
indL.pb(ind[i]);
else
indR.pb(ind[i]);
qr[ind[i]] = '0';
}
check(l, m, n, indL);
check(m + 1, r, n, indR);
}
vi restore_permutation(int n, int w, int r) {
add(0, n - 1, n);
compile_set();
vi ind;
for (int i = 0; i < n; i++)
ind.pb(i);
check(0, n - 1, n, ind);
vi ret;
for (int i = 0; i < n; i++)
ret.pb(ans[i]);
return ret;
}
/*int main()
{
return 0;
}*/
Compilation message (stderr)
messy.cpp: In function 'void check(int, int, int, std::vector<int>)':
messy.cpp:58:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < ind.size(); i++) qr[ind[i]] = '0';
~~^~~~~~~~~~~~
messy.cpp:60:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < ind.size(); i++) {
~~^~~~~~~~~~~~
# | 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... |