#include "doll.h"
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll i,Sa=0,DU[202020],j,TR;
vector<ll> v[202020],isi;
vector<int> C,XXI,YYI;
void gawe(ll aa,ll bb,ll cc,ll dd)
{
//cout<<i<<" "<<aa<<" "<<bb<<" "<<cc<<"\n";
if(aa==1)
{
// cout<<bb<<"\n";
XXI[dd]=(isi[bb]);
YYI[dd]=(isi[bb+(1<<(cc-1))]);
return ;
}
TR++;
XXI[dd]=-TR-1;
gawe(aa-1,bb,cc,TR);
TR++;
YYI[dd]=-TR-1;
// cout<<i<<" "<<cc<<" "<<aa<<" "<<(1<<(cc-aa))<<"\n";
gawe(aa-1,bb+(1<<(cc-aa)),cc,TR);
}
void create_circuit(int M, std::vector<int> A) {
int N = A.size();
for(i=0;i<=M;i++)
C.pb(0);
v[0].pb(A[0]);
for(i=0;i<N-1;i++)
v[A[i]].pb(A[i+1]);
for(i=0;i<=200000;i++)
{
for(j=20;j>=0;j--)
{
ll HA=(1<<j);
if(HA>=i)
DU[i]=j;
}
}
v[A[N-1]].pb(0);
//return ;
for(i=0;i<=M;i++)
{
if(v[i].size()==0)
continue;
else
if(v[i].size()==1)
{
// cout<<v[i][0]<<"\n";
C[i]=v[i][0];
continue;
}
else
{
C[i]=-TR-1;
ll SZ=v[i].size();
ll GED=DU[SZ];
//cout<<SZ<<" "<<GED<<"\n";
isi.clear();
// cout<<GED<<"GED\n";
for(j=0;j<((1<<GED)-SZ);j++)
isi.pb(-TR-1);
for(j=0;j<v[i].size();j++)
isi.pb(v[i][j]);
for(j=0;j<isi.size()+20;j++)
{
XXI.pb(0);
YYI.pb(0);
// cout<<j<<" "<<isi[j]<<"\n";
}
gawe(GED,0,GED,TR);
TR=XXI.size();
while((TR-1>=0)&&(XXI[TR-1]==0)&&(YYI[TR-1]==0))
{
XXI.pop_back();
YYI.pop_back();
TR--;
}
TR++;
// TR+=isi.size();
//TR+=GED;
}
}
//for(i=0;i<=M;i++)cout<<i<<" "<<C[i]<<"\n";
//for(i=0;i<XXI.size();i++)cout<<-i-1<<" "<<XXI[i]<<" "<<YYI[i]<<"\n";
// cout<<C.size()<<" "<<XXI.size()<<" "<<YYI.size()<<"\n";
if(XXI.size()>N*2)
while(1);
answer(C, XXI, YYI);
}
Compilation message
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:69:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
69 | for(j=0;j<v[i].size();j++)
| ~^~~~~~~~~~~~
doll.cpp:71:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
71 | for(j=0;j<isi.size()+20;j++)
| ~^~~~~~~~~~~~~~
doll.cpp:93:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
93 | if(XXI.size()>N*2)
| ~~~~~~~~~~^~~~
doll.cpp:93:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
93 | if(XXI.size()>N*2)
| ^~
doll.cpp:95:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
95 | answer(C, XXI, YYI);
| ^~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
6604 KB |
Output is correct |
2 |
Correct |
53 ms |
10320 KB |
Output is correct |
3 |
Correct |
37 ms |
10036 KB |
Output is correct |
4 |
Correct |
9 ms |
6604 KB |
Output is correct |
5 |
Correct |
26 ms |
7876 KB |
Output is correct |
6 |
Correct |
61 ms |
11624 KB |
Output is correct |
7 |
Correct |
9 ms |
6604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
6604 KB |
Output is correct |
2 |
Correct |
53 ms |
10320 KB |
Output is correct |
3 |
Correct |
37 ms |
10036 KB |
Output is correct |
4 |
Correct |
9 ms |
6604 KB |
Output is correct |
5 |
Correct |
26 ms |
7876 KB |
Output is correct |
6 |
Correct |
61 ms |
11624 KB |
Output is correct |
7 |
Correct |
9 ms |
6604 KB |
Output is correct |
8 |
Correct |
113 ms |
14532 KB |
Output is correct |
9 |
Correct |
92 ms |
13792 KB |
Output is correct |
10 |
Correct |
168 ms |
17840 KB |
Output is correct |
11 |
Correct |
15 ms |
6604 KB |
Output is correct |
12 |
Correct |
11 ms |
6656 KB |
Output is correct |
13 |
Correct |
11 ms |
6552 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
6604 KB |
Output is correct |
2 |
Correct |
53 ms |
10320 KB |
Output is correct |
3 |
Correct |
37 ms |
10036 KB |
Output is correct |
4 |
Correct |
9 ms |
6604 KB |
Output is correct |
5 |
Correct |
26 ms |
7876 KB |
Output is correct |
6 |
Correct |
61 ms |
11624 KB |
Output is correct |
7 |
Correct |
9 ms |
6604 KB |
Output is correct |
8 |
Correct |
113 ms |
14532 KB |
Output is correct |
9 |
Correct |
92 ms |
13792 KB |
Output is correct |
10 |
Correct |
168 ms |
17840 KB |
Output is correct |
11 |
Correct |
15 ms |
6604 KB |
Output is correct |
12 |
Correct |
11 ms |
6656 KB |
Output is correct |
13 |
Correct |
11 ms |
6552 KB |
Output is correct |
14 |
Incorrect |
171 ms |
19672 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
12 ms |
6604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
10 ms |
6580 KB |
Output is partially correct |
2 |
Correct |
74 ms |
13392 KB |
Output is correct |
3 |
Partially correct |
119 ms |
19992 KB |
Output is partially correct |
4 |
Partially correct |
127 ms |
20760 KB |
Output is partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
10 ms |
6580 KB |
Output is partially correct |
2 |
Correct |
74 ms |
13392 KB |
Output is correct |
3 |
Partially correct |
119 ms |
19992 KB |
Output is partially correct |
4 |
Partially correct |
127 ms |
20760 KB |
Output is partially correct |
5 |
Partially correct |
161 ms |
20860 KB |
Output is partially correct |
6 |
Partially correct |
151 ms |
21812 KB |
Output is partially correct |
7 |
Partially correct |
180 ms |
21432 KB |
Output is partially correct |
8 |
Partially correct |
162 ms |
22264 KB |
Output is partially correct |
9 |
Partially correct |
91 ms |
18296 KB |
Output is partially correct |
10 |
Partially correct |
155 ms |
22656 KB |
Output is partially correct |
11 |
Partially correct |
163 ms |
22716 KB |
Output is partially correct |
12 |
Partially correct |
92 ms |
17204 KB |
Output is partially correct |
13 |
Partially correct |
115 ms |
16524 KB |
Output is partially correct |
14 |
Partially correct |
108 ms |
16268 KB |
Output is partially correct |
15 |
Partially correct |
107 ms |
15912 KB |
Output is partially correct |
16 |
Partially correct |
14 ms |
6828 KB |
Output is partially correct |
17 |
Partially correct |
99 ms |
14716 KB |
Output is partially correct |
18 |
Partially correct |
98 ms |
14728 KB |
Output is partially correct |
19 |
Partially correct |
104 ms |
15388 KB |
Output is partially correct |
20 |
Partially correct |
134 ms |
17980 KB |
Output is partially correct |
21 |
Partially correct |
132 ms |
20384 KB |
Output is partially correct |
22 |
Partially correct |
106 ms |
16940 KB |
Output is partially correct |