#include "doll.h"
#include<bits/stdc++.h>
using namespace std ;
typedef pair<int,int> pii ;
#define fi first
#define se second
const int N = 2e5+9 ;
#define mid (l+r>>1)
vector<pii> pos ;
int n,L[N<<4],R[N<<4],id=1,a[N<<1],f[N<<1];
int construct(int l,int r,int x,int m)
{
if(r<x)
{
id--;
return -1 ;
}
if(l==r)
{
id--;
return a[l];
}
L[m]=construct(l,mid,x,++id);
R[m]=construct(mid+1,r,x,++id);
return -m ;
}
void create_circuit(int M, vector<int> A)
{
n=A.size()+1;
A.push_back(0);
int sz ;
for(sz=1;sz<n;sz<<=1);
f[1]=1;
for(int len=sz/2,idx=1;len;len/=2,idx*=2)
{
for(int j=1;j<=idx;j++)f[j+idx]=f[j]+len ;
}
for(int i=sz-n+1;i<=sz;i++)pos.push_back({f[i],i});
sort(pos.begin(),pos.end());
int ptr = 0 ;
for(auto it:pos)a[it.se]=A[ptr++];
construct(1,sz,sz-n+1,1);
vector<int> X(id),Y(id),C(M+1);
for(int i=0;i<=M;i++)C[i]=-1;
for(int i=1;i<=id;i++)
{
X[i-1]=L[i];
Y[i-1]=R[i];
}
answer(C,X,Y);
}
Compilation message
doll.cpp: In function 'int construct(int, int, int, int)':
doll.cpp:8:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
8 | #define mid (l+r>>1)
| ~^~
doll.cpp:23:22: note: in expansion of macro 'mid'
23 | L[m]=construct(l,mid,x,++id);
| ^~~
doll.cpp:8:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
8 | #define mid (l+r>>1)
| ~^~
doll.cpp:24:20: note: in expansion of macro 'mid'
24 | R[m]=construct(mid+1,r,x,++id);
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
54 ms |
6200 KB |
Output is correct |
3 |
Correct |
50 ms |
5680 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
12 ms |
1484 KB |
Output is correct |
6 |
Correct |
59 ms |
8268 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
54 ms |
6200 KB |
Output is correct |
3 |
Correct |
50 ms |
5680 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
12 ms |
1484 KB |
Output is correct |
6 |
Correct |
59 ms |
8268 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
74 ms |
10172 KB |
Output is correct |
9 |
Correct |
78 ms |
10664 KB |
Output is correct |
10 |
Correct |
128 ms |
14848 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
3 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
54 ms |
6200 KB |
Output is correct |
3 |
Correct |
50 ms |
5680 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
12 ms |
1484 KB |
Output is correct |
6 |
Correct |
59 ms |
8268 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
74 ms |
10172 KB |
Output is correct |
9 |
Correct |
78 ms |
10664 KB |
Output is correct |
10 |
Correct |
128 ms |
14848 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
3 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
153 ms |
14348 KB |
Output is correct |
15 |
Correct |
77 ms |
9632 KB |
Output is correct |
16 |
Correct |
123 ms |
14108 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
128 ms |
14540 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
74 ms |
8708 KB |
Output is correct |
3 |
Correct |
78 ms |
8688 KB |
Output is correct |
4 |
Correct |
136 ms |
12640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
74 ms |
8708 KB |
Output is correct |
3 |
Correct |
78 ms |
8688 KB |
Output is correct |
4 |
Correct |
136 ms |
12640 KB |
Output is correct |
5 |
Correct |
142 ms |
13884 KB |
Output is correct |
6 |
Correct |
103 ms |
13596 KB |
Output is correct |
7 |
Correct |
123 ms |
13668 KB |
Output is correct |
8 |
Correct |
122 ms |
13404 KB |
Output is correct |
9 |
Correct |
87 ms |
8608 KB |
Output is correct |
10 |
Correct |
102 ms |
13332 KB |
Output is correct |
11 |
Correct |
136 ms |
12988 KB |
Output is correct |
12 |
Correct |
65 ms |
8872 KB |
Output is correct |
13 |
Correct |
68 ms |
9348 KB |
Output is correct |
14 |
Correct |
89 ms |
9400 KB |
Output is correct |
15 |
Correct |
67 ms |
9540 KB |
Output is correct |
16 |
Correct |
4 ms |
644 KB |
Output is correct |
17 |
Correct |
63 ms |
8392 KB |
Output is correct |
18 |
Correct |
93 ms |
8860 KB |
Output is correct |
19 |
Correct |
63 ms |
8888 KB |
Output is correct |
20 |
Correct |
103 ms |
13164 KB |
Output is correct |
21 |
Correct |
137 ms |
12960 KB |
Output is correct |
22 |
Correct |
117 ms |
12956 KB |
Output is correct |