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 <vector>
#include <stdio.h>
using namespace std;
int con[1000005]={0};
int This[1000005]={0};
int m[1000005];
int n[1000005];
int start[1000005]={0};
vector < int > C,x,y;
int X[1000005]={0};
int Y[1000005]={0};
int now=1;
int t[1000005]={0};
void build(int N,int here,int n,int all,int x)
{
//printf("%d %d %d %d\n",N,here,n,all);
if(n==all-1)
{
if(N%2) Y[-here]=x;
else X[-here]=x;
return ;
}
if(N%2)
{
if(!Y[-here])
{
Y[-here]=-now;
now++;
}
build(N/2,Y[-here],n+1,all,x);
}
else
{
if(!X[-here])
{
X[-here]=-now;
now++;
}
build(N/2,X[-here],n+1,all,x);
}
}
void create_circuit(int M, vector < int > A)
{
int N=A.size(),i,temp;
C.push_back(A[0]);
for(i=1;i<=M;i++) C.push_back(i);
for(i=0;i<N;i++) con[A[i]]++;
A.push_back(0);
for(i=0;i<N;i++)
{
if(con[A[i]]==1)
{
C[A[i]]=A[i+1];
}
else
{
if(!This[A[i]])
{
C[A[i]]=-now;
now++;
t[A[i]]=0;
temp=1;
while(temp<con[A[i]])
{
temp*=2;
t[A[i]]++;
}
start[A[i]]=temp-con[A[i]];
for(int j=0;j<temp;j++) build(j,C[A[i]],0,t[A[i]],C[A[i]]);
}
build(This[A[i]]+start[A[i]],C[A[i]],0,t[A[i]],A[i+1]);
This[A[i]]++;
}
}
//for(auto i:C) printf("%d ",i);
//printf("\n");
//for(i=1;i<now;i++) printf("%d %d\n",X[i],Y[i]);
for(i=1;i<now;i++) x.push_back(X[i]);
for(i=1;i<now;i++) y.push_back(Y[i]);
answer(C,x,y);
}
| # | 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... |