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 "doll.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define f first
#define s second
#define all(a) (a).begin(),(a).end()
#define For(i,a,b) for(auto i=(a);i<(b);i++)
#define FOR(i,b) For(i,0,b)
#define Rev(i,a,b) for(auto i=(a);i>(b);i--)
#define REV(i,a) Rev(i,a,-1)
#define FORE(i,a) for(auto&&i:a)
#define sz(a) (int((a).size()))
using ll=long long;using ld=long double;using uint=unsigned int;using ull=unsigned long long;
using pii=pair<int,int>;using pll=pair<ll,ll>;using pill=pair<int,ll>;using plli=pair<ll,int>;using pdd=pair<double,double>;using pld=pair<ld,ld>;
constexpr const char nl='\n',sp=' ';constexpr const int INT_INF=0x3f3f3f3f;constexpr const ll LL_INF=0x3f3f3f3f3f3f3f3f;
constexpr const double D_INF=numeric_limits<double>::infinity();constexpr const ld LD_INF=numeric_limits<ld>::infinity();constexpr const double EPS=1e-9;
const int MAXN = 2e5 + 5;
int N, H, cur = 1, X[MAXN], Y[MAXN];
bool T[MAXN];
int build(int l, int r) {
if (l >= r) return 0;
if (r < H - N) return 1;
int m = l + (r - l) / 2, ret = cur++;
T[ret] = false;
X[ret] = build(l, m);
Y[ret] = build(m + 1, r);
return ret;
}
void update(int i, int a) {
int &j = T[i] ? Y[i] : X[i];
T[i] = !T[i];
assert(j >= 0);
if (j == 0) j = -a;
else update(j, a);
}
void create_circuit(int M, vector<int> A) {
N = A.size();
for (H = 1; H < N; H *= 2);
build(0, H - 1);
For(i, 1, sz(A)) update(1, A[i]);
if (N % 2) update(1, 1);
update(1, 0);
For(i, 1, cur) {
assert(!T[i]);
X[i] = -X[i];
Y[i] = -Y[i];
}
vector<int> C(M + 1, -1);
C[0] = A[0];
answer(C, vector<int>(X + 1, X + cur), vector<int>(Y + 1, Y + cur));
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |