#include "doll.h"
#define here cerr<<"===========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define ld double
#define ll int
#define llinf 100000000000000000LL // 10^17
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) (ll)(a.size())
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {cerr<<#a<<": ";for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
#define cer(a) {cerr<<#a<<": ";for(ll x_ : a) cerr<<x_<< " ";cerr<<endl;}
#define daj_mi_malo_vremena ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);
using namespace std;
using namespace __gnu_pbds;
#define maxn 400005
ll n,m;
ll a[maxn];
ll pos[maxn],ls[maxn],rs[maxn];
ll it = 0,k,rut;
vector<ll> reshi(vector<ll> v){
if(sz(v)<=1) return v;
vector<vector<ll> > u(2);
for(ll i = 0;i<sz(v);i++) u[i&1].pb(v[i]);
u[0] = reshi(u[0]); u[1] = reshi(u[1]);
v.clear();
for(ll x : u[0]) v.pb(x);
for(ll x : u[1]) v.pb(x);
return v;
}
void reshi(ll &v,ll tl,ll tr){
if(tr<=k){v = rut;return;}
if(tl==tr){v = -a[tl];return;}
v = ++it;
ll mid = (tl+tr)/2;
reshi(ls[v],tl,mid);
reshi(rs[v],mid+1,tr);
}
void create_circuit(int M, vector<int> A) {
A.pb(0);
n = sz(A); m = M;
ll d = 1;
while(d<n) d*=2;
vector<ll> v(d); iota(all(v),1);
v = reshi(v);
k = d-n;
for(ll i = k;i<d;i++) pos[v[i]] = i+1;
for(ll i = 1,j = 0;i<=d;i++){
if(pos[i]){
a[pos[i]] = A[j]; j++;
}
}
reshi(rut,1,d);
vector<ll> C(m+1,-1),X,Y;
for(ll i = 1;i<=it;i++) X.pb(-ls[i]),Y.pb(-rs[i]);
answer(C,X,Y);
}
/*
4 4
1 2 1 3
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
57 ms |
5828 KB |
Output is correct |
3 |
Correct |
56 ms |
5556 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
8 ms |
1492 KB |
Output is correct |
6 |
Correct |
71 ms |
8036 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
57 ms |
5828 KB |
Output is correct |
3 |
Correct |
56 ms |
5556 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
8 ms |
1492 KB |
Output is correct |
6 |
Correct |
71 ms |
8036 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
107 ms |
9408 KB |
Output is correct |
9 |
Correct |
111 ms |
10032 KB |
Output is correct |
10 |
Correct |
133 ms |
13496 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
57 ms |
5828 KB |
Output is correct |
3 |
Correct |
56 ms |
5556 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
8 ms |
1492 KB |
Output is correct |
6 |
Correct |
71 ms |
8036 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
107 ms |
9408 KB |
Output is correct |
9 |
Correct |
111 ms |
10032 KB |
Output is correct |
10 |
Correct |
133 ms |
13496 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
145 ms |
13004 KB |
Output is correct |
15 |
Correct |
105 ms |
10132 KB |
Output is correct |
16 |
Correct |
127 ms |
15204 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
133 ms |
14876 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
308 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
104 ms |
9924 KB |
Output is correct |
3 |
Correct |
105 ms |
10064 KB |
Output is correct |
4 |
Correct |
122 ms |
13468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
104 ms |
9924 KB |
Output is correct |
3 |
Correct |
105 ms |
10064 KB |
Output is correct |
4 |
Correct |
122 ms |
13468 KB |
Output is correct |
5 |
Correct |
127 ms |
15112 KB |
Output is correct |
6 |
Correct |
128 ms |
15000 KB |
Output is correct |
7 |
Correct |
130 ms |
15116 KB |
Output is correct |
8 |
Correct |
129 ms |
14088 KB |
Output is correct |
9 |
Correct |
101 ms |
9924 KB |
Output is correct |
10 |
Correct |
122 ms |
14084 KB |
Output is correct |
11 |
Correct |
121 ms |
13832 KB |
Output is correct |
12 |
Correct |
109 ms |
9924 KB |
Output is correct |
13 |
Correct |
108 ms |
10032 KB |
Output is correct |
14 |
Correct |
127 ms |
10080 KB |
Output is correct |
15 |
Correct |
118 ms |
10160 KB |
Output is correct |
16 |
Correct |
4 ms |
596 KB |
Output is correct |
17 |
Correct |
77 ms |
9684 KB |
Output is correct |
18 |
Correct |
124 ms |
9924 KB |
Output is correct |
19 |
Correct |
115 ms |
9980 KB |
Output is correct |
20 |
Correct |
142 ms |
14104 KB |
Output is correct |
21 |
Correct |
140 ms |
13964 KB |
Output is correct |
22 |
Correct |
133 ms |
13836 KB |
Output is correct |