이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "doll.h"
#pragma GCC optimize("Ofast")
#define AquA cin.tie(0);ios_base::sync_with_stdio(0);
#define fs first
#define sc second
#define p_q priority_queue
using namespace std;
vector<int> g,x,y;
int nw=0;
vector<pair<int,int> > v;
vector<int> tp;
const int inf=1e9;
int build(int f,int sz){
queue<int> q;
q.push(f);
int cnt=0;
while(cnt<sz/2-1){
auto h=q.front();
q.pop();
x[h]=f+1;
y[h]=f+2;
q.push(f+1);
q.push(f+2);
f+=2;
cnt++;
}
return f+1;
}
void go(int z){
int root=0;
while(1){
if(tp[root]==0){
tp[root]=1;
if(x[root]==-1){
x[root]=inf+z;
break;
}
root=x[root];
}
else{
tp[root]=0;
if(y[root]==-1){
y[root]=inf+z;
break;
}
root=y[root];
}
}
}
void create_circuit(int m, vector<int> a) {
a.push_back(0);
int n=a.size();
g.clear();
g.resize(m+1,-1);
int root=0;
x.resize(400000,-1);
y.resize(400000,-1);
tp.resize(400000,0);
int flag=0;
for(int i=(1<<19);i>1;i>>=1){
if(n>=i){
flag=1;
n-=i;
int c=root+1;
x[root]=c;
int u=build(c,i);
y[root]=u;
root=u;
}
else{
if(!flag){
continue;
}
x[root]=0;
y[root]=root+1;
root++;
}
}
if(n%2){
x[root]=0;
}
else{
x[root]=y[root]=0;
}
x.resize(root+1);
y.resize(root+1);
n=a.size();
for(int i=0;i<n;i++){
go(a[i]);
}
for(int i=0;i<=root;i++){
if(x[i]>=inf){
x[i]-=inf;
}
else{
x[i]=-1-(x[i]);
}
if(y[i]>=inf){
y[i]-=inf;
}
else{
y[i]=-1-(y[i]);
}
}
answer(g,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... |