#include <bits/stdc++.h>
using namespace std;
#define a first
#define b second
#define pb push_back
#define mp make_pair
typedef long long llo;
#include "doll.h"
vector<int> pre[100001];
//vector<int> adj[100001];
vector<int> ac;
vector<int> x;
vector<int> y;
int cur=0;
int cot;
pair<int,int> adj[1000001];
int stt[1000001];
void con(int ind,int tot,int dd){
// x.pb(0);
//y.pb(0);
//cout<<dd<<".."<<endl;
//cout<<-cur<<"::"<<x.size()<<endl;
if(ind==tot-1){
/*x.pb(0);
y.pb(0);*/
}
else{
adj[-dd]={-cur+1,-cur+2};
//cout<<-dd<<":"<<-cur+1<<" "<<-cur+2<<endl;
/*if(-dd-1==3){
cout<<11<<endl;
}*/
//cout<<x.size()<<endl;
x[-dd-1]=cur-1;
y[-dd-1]=cur-2;
x.pb(0);
x.pb(0);
y.pb(0);
y.pb(0);
//cout<<-dd-1<<endl<<"::"<<cur-1<<endl;
// cout<<x[3]<<endl;
cur--;
cur--;
int ba=cur;
con(ind+1,tot,cur+1);
con(ind+1,tot,ba);
}
}
void create_circuit(int m, vector<int> aa) {
int n=aa.size();
for(int i=0;i<=m;i++){
ac.pb(0);
}
ac[0]=aa[0];
for(int i=0;i<aa.size()-1;i++){
pre[aa[i]].pb(aa[i+1]);
}
pre[aa.back()].pb(0);
/*for(int i=0;i<1000000;i++){
x.pb(0);
y.pb(0);
}
*/
for(int i=1;i<=m;i++){
cot=i;
if(pre[i].size()==0){
continue;
}
if(pre[i].size()==1){
ac[i]=pre[i][0];
}
else{
int xx=pre[i].size();
int dep=0;
for(int j=0;j<=19;j++){
if((1<<j)>=xx){
dep=j;
break;
}
}
// cout<<dep<<endl;
cur--;
ac[i]=cur;
x.pb(0);
y.pb(0);
con(0,dep,cur);
// continue;
int op=(1<<dep);
int ind2=0;
//continue;
for(int j=0;j<(1<<dep);j++){
int st=-ac[i];
//cout<<j<<",,"<<endl;
for(int jj=0;jj<dep-1;jj++){
if(stt[st]==0){
stt[st]=1-stt[st];
st=adj[st].a;
}
else{
stt[st]=1-stt[st];
st=adj[st].b;
}
}
op--;
//cout<<j<<":"<<st<<endl;
if(op<pre[i].size()){
//cout<<stt[st]<<",,"<<pre[i][ind2]<<endl;
if(stt[st]==0){
x[st-1]=pre[i][ind2];
}
else{
y[st-1]=pre[i][ind2];
}
stt[st]=1-stt[st];
ind2++;
}
else{
if(stt[st]==0){
x[st-1]=ac[i];
}
else{
y[st-1]=ac[i];
}
stt[st]=1-stt[st];
}
}
}
/*while(x.size()>-cur){
x.pop_back();
}
while(y.size()>-cur){
y.pop_back();
}*/
/*else if(pre[i].size()==2){
cur--;
ac[i]=cur;
x.pb(pre[i][0]);
y.pb(pre[i][1]);
}
else if(pre[i].size()==3){
cur--;
ac[i]=cur;
x.pb(cur-1);
y.pb(cur-2);
cur--;
x.pb(pre[i][0]);
y.pb(cur+1);
cur--;
x.pb(pre[i][1]);
y.pb(pre[i][2]);
}
else if(pre[i].size()==4){
cur--;
ac[i]=cur;
x.pb(cur-1);
y.pb(cur-2);
cur--;
x.pb(pre[i][0]);
y.pb(pre[i][2]);
cur--;
x.pb(pre[i][1]);
y.pb(pre[i][3]);
}*/
}
if(x.size()>2*n){
while(true){
continue;
}
}
/*while(x.size()>-cur){
x.pop_back();
}
while(y.size()>-cur){
y.pop_back();
}*/
/*for(auto j:ac){
cout<<j<<",";
}
cout<<endl;
for(auto j:x){
cout<<j<<",";
}
cout<<endl;
for(auto j:y){
cout<<j<<",";
}
cout<<endl;
*/
answer(ac,x,y);
}
Compilation message
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:59:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
59 | for(int i=0;i<aa.size()-1;i++){
| ~^~~~~~~~~~~~
doll.cpp:111:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
111 | if(op<pre[i].size()){
| ~~^~~~~~~~~~~~~~
doll.cpp:170:13: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
170 | if(x.size()>2*n){
| ~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
33 ms |
6272 KB |
Output is correct |
3 |
Correct |
27 ms |
6092 KB |
Output is correct |
4 |
Correct |
3 ms |
2636 KB |
Output is correct |
5 |
Correct |
15 ms |
3908 KB |
Output is correct |
6 |
Correct |
55 ms |
7652 KB |
Output is correct |
7 |
Correct |
2 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
33 ms |
6272 KB |
Output is correct |
3 |
Correct |
27 ms |
6092 KB |
Output is correct |
4 |
Correct |
3 ms |
2636 KB |
Output is correct |
5 |
Correct |
15 ms |
3908 KB |
Output is correct |
6 |
Correct |
55 ms |
7652 KB |
Output is correct |
7 |
Correct |
2 ms |
2652 KB |
Output is correct |
8 |
Correct |
58 ms |
9016 KB |
Output is correct |
9 |
Correct |
65 ms |
8880 KB |
Output is correct |
10 |
Correct |
98 ms |
11672 KB |
Output is correct |
11 |
Correct |
3 ms |
2636 KB |
Output is correct |
12 |
Correct |
3 ms |
2636 KB |
Output is correct |
13 |
Correct |
3 ms |
2636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
33 ms |
6272 KB |
Output is correct |
3 |
Correct |
27 ms |
6092 KB |
Output is correct |
4 |
Correct |
3 ms |
2636 KB |
Output is correct |
5 |
Correct |
15 ms |
3908 KB |
Output is correct |
6 |
Correct |
55 ms |
7652 KB |
Output is correct |
7 |
Correct |
2 ms |
2652 KB |
Output is correct |
8 |
Correct |
58 ms |
9016 KB |
Output is correct |
9 |
Correct |
65 ms |
8880 KB |
Output is correct |
10 |
Correct |
98 ms |
11672 KB |
Output is correct |
11 |
Correct |
3 ms |
2636 KB |
Output is correct |
12 |
Correct |
3 ms |
2636 KB |
Output is correct |
13 |
Correct |
3 ms |
2636 KB |
Output is correct |
14 |
Correct |
138 ms |
15836 KB |
Output is correct |
15 |
Correct |
55 ms |
8664 KB |
Output is correct |
16 |
Correct |
100 ms |
11920 KB |
Output is correct |
17 |
Correct |
3 ms |
2636 KB |
Output is correct |
18 |
Correct |
3 ms |
2636 KB |
Output is correct |
19 |
Correct |
3 ms |
2652 KB |
Output is correct |
20 |
Correct |
96 ms |
13972 KB |
Output is correct |
21 |
Correct |
2 ms |
2636 KB |
Output is correct |
22 |
Correct |
2 ms |
2636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2636 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
3 ms |
2636 KB |
Output is partially correct |
2 |
Correct |
75 ms |
9176 KB |
Output is correct |
3 |
Partially correct |
139 ms |
13636 KB |
Output is partially correct |
4 |
Partially correct |
152 ms |
14368 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
3 ms |
2636 KB |
Output is partially correct |
2 |
Correct |
75 ms |
9176 KB |
Output is correct |
3 |
Partially correct |
139 ms |
13636 KB |
Output is partially correct |
4 |
Partially correct |
152 ms |
14368 KB |
Output is partially correct |
5 |
Partially correct |
122 ms |
18000 KB |
Output is partially correct |
6 |
Partially correct |
133 ms |
19716 KB |
Output is partially correct |
7 |
Partially correct |
143 ms |
19164 KB |
Output is partially correct |
8 |
Partially correct |
130 ms |
20752 KB |
Output is partially correct |
9 |
Partially correct |
120 ms |
14704 KB |
Output is partially correct |
10 |
Partially correct |
164 ms |
21140 KB |
Output is partially correct |
11 |
Partially correct |
138 ms |
21652 KB |
Output is partially correct |
12 |
Partially correct |
107 ms |
15112 KB |
Output is partially correct |
13 |
Partially correct |
85 ms |
13820 KB |
Output is partially correct |
14 |
Partially correct |
81 ms |
13396 KB |
Output is partially correct |
15 |
Partially correct |
79 ms |
12556 KB |
Output is partially correct |
16 |
Partially correct |
5 ms |
2892 KB |
Output is partially correct |
17 |
Partially correct |
72 ms |
12244 KB |
Output is partially correct |
18 |
Partially correct |
73 ms |
12212 KB |
Output is partially correct |
19 |
Partially correct |
76 ms |
13088 KB |
Output is partially correct |
20 |
Partially correct |
103 ms |
15704 KB |
Output is partially correct |
21 |
Partially correct |
119 ms |
19024 KB |
Output is partially correct |
22 |
Partially correct |
94 ms |
14820 KB |
Output is partially correct |