이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<int(n);i++)
using namespace std;
static vector<int>rec(vector<int>&v){
if(v.size()==2)return v;
vector<int>a,b;
rep(i,v.size()){
if(i%2==0)a.push_back(v[i]);
else b.push_back(v[i]);
}
a=rec(a);
b=rec(b);
for(int i:b)a.push_back(i);
return a;
}
void create_circuit(int M, std::vector<int> A) {
A.push_back(0);
int N = A.size();
int n=2;while(n<N)n<<=1;
n>>=1;
vector<int>C(M+1);
vector<int>X(2*n-1),Y(2*n-1);
X=vector<int>();
Y=vector<int>();
C[0]=A[0];
rep(i,A.size()-1){
C[A[i]]=C[A[i+1]];
}
answer(C,X,Y);
return;
vector<int>idx(2*n);
rep(i,2*n)idx[i]=i;
idx=rec(idx);
for(int i=1;i<=2*n-1;i++){
if(i<=n-1){
X[i-1]=-(i*2);
Y[i-1]=-(i*2+1);
}
else{
int d=i-n;
int l=idx[2*d],r=idx[2*d+1];
if(l<N-1||l==2*n-1){
X[i-1]=A[l<N-1?l:N-1];
}
else X[i-1]=-1;
if(r<N-1||r==2*n-1){
Y[i-1]=A[r<N-1?r:N-1];
}
else Y[i-1]=-1;
}
}
rep(i,M+1)C[i]=-1;
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... |