This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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()+9;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+=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 (stderr)
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()+9;j++)
| ~^~~~~~~~~~~~~
doll.cpp:92:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
92 | if(XXI.size()>N*2)
| ~~~~~~~~~~^~~~
doll.cpp:92:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
92 | if(XXI.size()>N*2)
| ^~
doll.cpp:94:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
94 | answer(C, XXI, YYI);
| ^~~~~~| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |