#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;
vector <int> c,x,y,ve,o;
int n,sz=1,id,pos[1000001];
int f(int l, int r){
if (ve[l]==-1&&ve[r]==-1)
return INF;
if (l==r)
return ve[l];
int mid=(l+r)>>1,left=f(l,mid),right=f(mid+1,r);
x.push_back(left);
y.push_back(right);
id--;
return id;
}
vector <int> rearrange(int l, int r){
if (l==r)
return {l};
int mid=(l+r)>>1;
auto vl=rearrange(l,mid);
auto vr=rearrange(mid+1,r);
vector <int> ve;
for (int i=0;i<vl.size();i++){
ve.push_back(vl[i]);
ve.push_back(vr[i]);
}
return ve;
}
void create_circuit(int M, vector <int> A){
A.push_back(0);
n=A.size();
while (sz<n)
sz*=2;
ve=rearrange(0,sz-1);
for (int i=0;i<sz;i++)
pos[ve[i]]=i;
for (int i=0;i<sz-n;i++)
ve[i]=-1;
int j=-1;
for (int i:A){
j++;
while (pos[j]<sz-n)
j++;
ve[pos[j]]=i;
}
f(0,sz-1);
for (int &i:x)
if (i==INF)
i=id;
for (int i=0;i<=M;i++)
c.push_back(id);
answer(c,x,y);
}
Compilation message
doll.cpp: In function 'std::vector<int> rearrange(int, int)':
doll.cpp:25:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
25 | for (int i=0;i<vl.size();i++){
| ~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
35 ms |
7972 KB |
Output is correct |
3 |
Correct |
34 ms |
7768 KB |
Output is correct |
4 |
Correct |
0 ms |
600 KB |
Output is correct |
5 |
Correct |
8 ms |
1748 KB |
Output is correct |
6 |
Correct |
49 ms |
9860 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
35 ms |
7972 KB |
Output is correct |
3 |
Correct |
34 ms |
7768 KB |
Output is correct |
4 |
Correct |
0 ms |
600 KB |
Output is correct |
5 |
Correct |
8 ms |
1748 KB |
Output is correct |
6 |
Correct |
49 ms |
9860 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
64 ms |
11296 KB |
Output is correct |
9 |
Correct |
67 ms |
12048 KB |
Output is correct |
10 |
Correct |
85 ms |
15312 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
35 ms |
7972 KB |
Output is correct |
3 |
Correct |
34 ms |
7768 KB |
Output is correct |
4 |
Correct |
0 ms |
600 KB |
Output is correct |
5 |
Correct |
8 ms |
1748 KB |
Output is correct |
6 |
Correct |
49 ms |
9860 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
64 ms |
11296 KB |
Output is correct |
9 |
Correct |
67 ms |
12048 KB |
Output is correct |
10 |
Correct |
85 ms |
15312 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
80 ms |
15132 KB |
Output is correct |
15 |
Correct |
61 ms |
10480 KB |
Output is correct |
16 |
Correct |
80 ms |
14256 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
82 ms |
15272 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
57 ms |
8436 KB |
Output is correct |
3 |
Correct |
57 ms |
8436 KB |
Output is correct |
4 |
Correct |
77 ms |
11344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
57 ms |
8436 KB |
Output is correct |
3 |
Correct |
57 ms |
8436 KB |
Output is correct |
4 |
Correct |
77 ms |
11344 KB |
Output is correct |
5 |
Correct |
78 ms |
12724 KB |
Output is correct |
6 |
Correct |
79 ms |
13536 KB |
Output is correct |
7 |
Correct |
81 ms |
14016 KB |
Output is correct |
8 |
Correct |
77 ms |
13228 KB |
Output is correct |
9 |
Correct |
57 ms |
9244 KB |
Output is correct |
10 |
Correct |
76 ms |
13232 KB |
Output is correct |
11 |
Correct |
73 ms |
12720 KB |
Output is correct |
12 |
Correct |
57 ms |
9464 KB |
Output is correct |
13 |
Correct |
59 ms |
9972 KB |
Output is correct |
14 |
Correct |
60 ms |
10220 KB |
Output is correct |
15 |
Correct |
60 ms |
10272 KB |
Output is correct |
16 |
Correct |
2 ms |
600 KB |
Output is correct |
17 |
Correct |
42 ms |
9432 KB |
Output is correct |
18 |
Correct |
62 ms |
9716 KB |
Output is correct |
19 |
Correct |
57 ms |
9460 KB |
Output is correct |
20 |
Correct |
75 ms |
12984 KB |
Output is correct |
21 |
Correct |
74 ms |
12720 KB |
Output is correct |
22 |
Correct |
73 ms |
12852 KB |
Output is correct |