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 <bits/stdc++.h>
#include "doll.h"
using namespace std;
const int MAX = 1e5+10;
vector<int> g[MAX], ans, ansx, ansy;
int out[MAX], x[MAX], y[MAX];
int qtdS, n;
int New()
{
int ret = -(++qtdS);
return ret;
}
void Build(int v,vector<int> ord)
{
int k = - v - 1;
int grau = ord.size();
if( grau == 2 )
{
x[k] = ord[0];
y[k] = ord[1];
return;
}
vector<int> first, second;
if(grau % 2)
{
first.push_back( v ), second.push_back(ord[0]);
for(int i=1;i<grau;i++)
{
int prox = ord[i];
if(i%2) first.push_back(prox);
else second.push_back(prox);
}
}
else
{
for(int i=0;i<grau;i++)
{
int prox = ord[i];
if(i%2) second.push_back(prox);
else first.push_back(prox);
}
}
int n1 = New(), n2 = New();
x[k] = n1; y[k] = n2;
Build(n1,first); Build(n2,second);
return;
}
void SetSwitch(int v)
{
int grau = g[v].size();
if(grau == 0){ out[v] = 0; return; }
if(grau == 1){ out[v] = g[v][0]; return; }
out[v] = New() ;
Build( out[v], g[v] );
return;
}
void create_circuit(int M, vector<int> A)
{
n = A.size();
g[0].push_back(A[0]);
for(int i=0;i<n-1;i++)
{
g[A[i]].push_back(A[i+1]);
}
g[A[n-1]].push_back(0);
for(int i=0;i<=M;i++)
{
SetSwitch( i );
}
for(int i=0;i<=M;i++) ans.push_back(out[i]);
for(int i=0;i<qtdS;i++) ansx.push_back(x[i]), ansy.push_back(y[i]);
answer(ans,ansx,ansy);
return;
}
# | 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... |