#include "doll.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
typedef pair < long long, long long > pll;
typedef pair < int, int > pii;
typedef unsigned long long ull;
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;
typedef long long ll;
typedef double db;
typedef tree < int, null_type, less < int >, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
const int inf = 1e9, maxn = 2e5 + 48, mod = 998244353, N = 1e6 + 12;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 300;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = acos(-1);
const ll INF = 1e18;
int n, m, s, k, X[N], Y[N];
vi c, x, y, g[N];
bool ok[N << 2];
void build (int p, int v, int u, int tl, int tr) {
if (tl == tr - 1) {
if (u >= tl)
X[v] = p;
return;
}
int tm = (tl + tr) >> 1;
if (u < tm)
X[v] = ++s;
else
X[v] = p;
Y[v] = ++s;
if (X[v] != p)
build(p, X[v], u, tl, tm);
build(p, Y[v], u, tm + 1, tr);
}
void upd (int p, int v, int u, int tl, int tr) {
// cerr << v << endl;
ok[v] ^= 1;
if (tl == tr - 1) {
// cerr << "--> " << tl << ' ' << tr << ' ' << v << ' ' << u << endl;
if (ok[v]) {
if (X[v] == p) {
upd(p, p, u, 0, (1 << k) - 1);
return;
}
X[v] = -u;
} else
Y[v] = -u;
return;
}
int tm = (tl + tr) >> 1;
if (ok[v]) {
if (X[v] == p)
upd(p, X[v], u, 0, (1 << k) - 1);
else
upd(p, X[v], u, tl, tm);
} else
upd(p, Y[v], u, tm + 1, tr);
}
void create_circuit(int _m, vi a) {
m = _m;
n = sz(a);
c.resize(m + 1);
a.pb(0);
c[0] = a[0];
k = 0;
while ((1 << k) < sz(a))
++k;
c[0] = -(++s);
build(s, s, (1 << k) - sz(a) - 1, 0, (1 << k) - 1);
for (auto x : a)
upd(1, 1, x, 0, (1 << k) - 1);
for (int i = 1; i <= s; ++i) {
x.pb(-X[i]);
y.pb(-Y[i]);
}
for (int i = 1; i <= m; ++i)
c[i] = -1;
/*
for (int i = 0; i <= m; ++i)
cerr << c[i] << ' ';
cerr << endl;
cerr << sz(x) << ' ' << sz(y) << endl;
for (int i = 0; i < sz(x); ++i)
cerr << x[i] << ' ' << y[i] << endl;
*/
answer(c, x, y);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
23756 KB |
Output is correct |
2 |
Correct |
60 ms |
28360 KB |
Output is correct |
3 |
Correct |
57 ms |
28220 KB |
Output is correct |
4 |
Correct |
19 ms |
23756 KB |
Output is correct |
5 |
Correct |
27 ms |
24948 KB |
Output is correct |
6 |
Correct |
95 ms |
30176 KB |
Output is correct |
7 |
Correct |
19 ms |
23700 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
23756 KB |
Output is correct |
2 |
Correct |
60 ms |
28360 KB |
Output is correct |
3 |
Correct |
57 ms |
28220 KB |
Output is correct |
4 |
Correct |
19 ms |
23756 KB |
Output is correct |
5 |
Correct |
27 ms |
24948 KB |
Output is correct |
6 |
Correct |
95 ms |
30176 KB |
Output is correct |
7 |
Correct |
19 ms |
23700 KB |
Output is correct |
8 |
Correct |
96 ms |
31196 KB |
Output is correct |
9 |
Correct |
109 ms |
31736 KB |
Output is correct |
10 |
Correct |
142 ms |
35108 KB |
Output is correct |
11 |
Correct |
17 ms |
23888 KB |
Output is correct |
12 |
Correct |
20 ms |
23712 KB |
Output is correct |
13 |
Correct |
20 ms |
23756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
23756 KB |
Output is correct |
2 |
Correct |
60 ms |
28360 KB |
Output is correct |
3 |
Correct |
57 ms |
28220 KB |
Output is correct |
4 |
Correct |
19 ms |
23756 KB |
Output is correct |
5 |
Correct |
27 ms |
24948 KB |
Output is correct |
6 |
Correct |
95 ms |
30176 KB |
Output is correct |
7 |
Correct |
19 ms |
23700 KB |
Output is correct |
8 |
Correct |
96 ms |
31196 KB |
Output is correct |
9 |
Correct |
109 ms |
31736 KB |
Output is correct |
10 |
Correct |
142 ms |
35108 KB |
Output is correct |
11 |
Correct |
17 ms |
23888 KB |
Output is correct |
12 |
Correct |
20 ms |
23712 KB |
Output is correct |
13 |
Correct |
20 ms |
23756 KB |
Output is correct |
14 |
Correct |
138 ms |
34680 KB |
Output is correct |
15 |
Correct |
94 ms |
30640 KB |
Output is correct |
16 |
Correct |
131 ms |
34376 KB |
Output is correct |
17 |
Correct |
20 ms |
23756 KB |
Output is correct |
18 |
Correct |
17 ms |
23712 KB |
Output is correct |
19 |
Correct |
16 ms |
23808 KB |
Output is correct |
20 |
Correct |
142 ms |
34792 KB |
Output is correct |
21 |
Correct |
20 ms |
23756 KB |
Output is correct |
22 |
Correct |
15 ms |
23756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
23784 KB |
Output is correct |
2 |
Correct |
17 ms |
23800 KB |
Output is correct |
3 |
Correct |
22 ms |
23756 KB |
Output is correct |
4 |
Correct |
24 ms |
23704 KB |
Output is correct |
5 |
Correct |
15 ms |
23756 KB |
Output is correct |
6 |
Correct |
16 ms |
23756 KB |
Output is correct |
7 |
Correct |
18 ms |
23756 KB |
Output is correct |
8 |
Correct |
16 ms |
23760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
23756 KB |
Output is correct |
2 |
Correct |
92 ms |
29704 KB |
Output is correct |
3 |
Correct |
84 ms |
29656 KB |
Output is correct |
4 |
Correct |
133 ms |
32872 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
23756 KB |
Output is correct |
2 |
Correct |
92 ms |
29704 KB |
Output is correct |
3 |
Correct |
84 ms |
29656 KB |
Output is correct |
4 |
Correct |
133 ms |
32872 KB |
Output is correct |
5 |
Correct |
155 ms |
34264 KB |
Output is correct |
6 |
Correct |
148 ms |
33888 KB |
Output is correct |
7 |
Correct |
154 ms |
34008 KB |
Output is correct |
8 |
Correct |
134 ms |
33688 KB |
Output is correct |
9 |
Correct |
87 ms |
29728 KB |
Output is correct |
10 |
Correct |
127 ms |
33548 KB |
Output is correct |
11 |
Correct |
135 ms |
33200 KB |
Output is correct |
12 |
Correct |
93 ms |
29996 KB |
Output is correct |
13 |
Correct |
99 ms |
30328 KB |
Output is correct |
14 |
Correct |
131 ms |
30384 KB |
Output is correct |
15 |
Correct |
115 ms |
30564 KB |
Output is correct |
16 |
Correct |
17 ms |
24012 KB |
Output is correct |
17 |
Correct |
103 ms |
30324 KB |
Output is correct |
18 |
Correct |
84 ms |
29856 KB |
Output is correct |
19 |
Correct |
91 ms |
29984 KB |
Output is correct |
20 |
Correct |
134 ms |
33516 KB |
Output is correct |
21 |
Correct |
133 ms |
33272 KB |
Output is correct |
22 |
Correct |
158 ms |
33316 KB |
Output is correct |