#include "bits/stdc++.h"
#include "doll.h"
using namespace std;
int seg[800001];
int ad;
int swp[800001];
int S = -1;
vector<int> X,Y,C;
bool ss = 0;
void add(int p,int l,int r,int val){
if(r<=ad)return ;
if(l==r){
seg[p] = val;
ss = 1;
return ;
}
int md = (l+r)/2;
if(swp[p]==0){
add(p*2,l,md,val);
}else{
add(p*2+1,md+1,r,val);
}
swp[p] = !swp[p];
}
int build(int p,int l,int r){
if(r<=ad)return -1e9;
if(l==r)return seg[p];
int md = (l+r)/2;
int x = build(p*2,l,md);
int y = build(p*2+1,md+1,r);
if(x==-1e9)X.push_back(-1e9);
else X.push_back(x);
if(y==-1e9)assert(0);
Y.push_back(y);
return S--;
}
vector<int> dc(vector<int> lol){
if(lol.size()==1)return lol;
int sz = lol.size();
int add = sz/2;
vector<int> ret;
for(auto i:lol){
cout<<i<<" ";
}
cout<<endl;
for(int j = 0;j+add<sz;j++){
if(lol[j]==-1e9&&lol[j+add]==-1e9){
ret.push_back(-1e9);
continue;
}
if(lol[j]==-1e9)X.push_back(S);
else X.push_back(lol[j]);
Y.push_back(lol[j+add]);
ret.push_back(S--);
}
return dc(ret);
}
void create_circuit(int M, vector<int> A){
S = -1;
X.clear();
Y.clear();
C.clear();
vector<int> adj[M+1];
int N = A.size();
vector<int> lo;
for(int i = 1;i<N;i++){
lo.push_back(A[i]);
}
lo.push_back(0);
int rem = 1;
while(rem<lo.size())rem*=2;
ad = rem - (long long)(lo.size());
for(auto i:lo){
ss = 0;
while(ss==0){
ss = 0;
add(1,1,rem,i);
}
}
int v = build(1,1,rem);
for(int i = 0;i<X.size();i++){
if(X[i]==-1e9)X[i] = v;
if(Y[i]==-1e9)Y[i] = v;
}
C.push_back(A[0]);
for(int i = 1;i<=M;i++){
if(rem!=1)C.push_back(v);
else C.push_back(0);
}
answer(C,X,Y);
}
Compilation message
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:74:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
74 | while(rem<lo.size())rem*=2;
| ~~~^~~~~~~~~~
doll.cpp:85:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
85 | for(int i = 0;i<X.size();i++){
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
20 ms |
9140 KB |
Output is correct |
3 |
Correct |
21 ms |
8264 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
6 ms |
6100 KB |
Output is correct |
6 |
Correct |
30 ms |
10148 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
20 ms |
9140 KB |
Output is correct |
3 |
Correct |
21 ms |
8264 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
6 ms |
6100 KB |
Output is correct |
6 |
Correct |
30 ms |
10148 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
40 ms |
10044 KB |
Output is correct |
9 |
Correct |
43 ms |
13156 KB |
Output is correct |
10 |
Correct |
55 ms |
15076 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
0 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
20 ms |
9140 KB |
Output is correct |
3 |
Correct |
21 ms |
8264 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
6 ms |
6100 KB |
Output is correct |
6 |
Correct |
30 ms |
10148 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
40 ms |
10044 KB |
Output is correct |
9 |
Correct |
43 ms |
13156 KB |
Output is correct |
10 |
Correct |
55 ms |
15076 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
0 ms |
2396 KB |
Output is correct |
14 |
Correct |
52 ms |
13772 KB |
Output is correct |
15 |
Correct |
36 ms |
11244 KB |
Output is correct |
16 |
Correct |
78 ms |
14320 KB |
Output is correct |
17 |
Correct |
0 ms |
2396 KB |
Output is correct |
18 |
Correct |
0 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
52 ms |
15604 KB |
Output is correct |
21 |
Correct |
1 ms |
2392 KB |
Output is correct |
22 |
Correct |
0 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2392 KB |
Output is correct |
3 |
Correct |
0 ms |
2468 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
32 ms |
7780 KB |
Output is correct |
3 |
Correct |
31 ms |
8296 KB |
Output is correct |
4 |
Correct |
46 ms |
12528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
32 ms |
7780 KB |
Output is correct |
3 |
Correct |
31 ms |
8296 KB |
Output is correct |
4 |
Correct |
46 ms |
12528 KB |
Output is correct |
5 |
Correct |
50 ms |
14068 KB |
Output is correct |
6 |
Correct |
50 ms |
13408 KB |
Output is correct |
7 |
Correct |
49 ms |
13556 KB |
Output is correct |
8 |
Correct |
50 ms |
13016 KB |
Output is correct |
9 |
Correct |
34 ms |
9192 KB |
Output is correct |
10 |
Correct |
47 ms |
12788 KB |
Output is correct |
11 |
Correct |
47 ms |
12532 KB |
Output is correct |
12 |
Correct |
38 ms |
9420 KB |
Output is correct |
13 |
Correct |
32 ms |
9164 KB |
Output is correct |
14 |
Correct |
33 ms |
10468 KB |
Output is correct |
15 |
Correct |
34 ms |
10732 KB |
Output is correct |
16 |
Correct |
2 ms |
2652 KB |
Output is correct |
17 |
Correct |
29 ms |
8908 KB |
Output is correct |
18 |
Correct |
30 ms |
8912 KB |
Output is correct |
19 |
Correct |
35 ms |
9704 KB |
Output is correct |
20 |
Correct |
48 ms |
12788 KB |
Output is correct |
21 |
Correct |
48 ms |
12528 KB |
Output is correct |
22 |
Correct |
46 ms |
12724 KB |
Output is correct |