#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
void create_circuit(int m, vector<int> a) {
int n = a.size();
int len = 0;
int cnt = -2;
while((1<<len) < n + 99999)len++;
vector <int> c(m + 1);
vector <int> x((1<<len) - 1);
vector <int> y((1<<len) - 1);
vector <int> x2((1<<len) - 1);
vector <int> y2((1<<len) - 1);
vector <int> d((1<<len) - 1);
vector <int> ok((1<<len) - 1);
vector <int> mrk((1<<len) - 1);
vector <int> ord;
vector <int> ord2;
vector <int> ord3;
for(int i = 0;i < m + 1;i++){
c[i] = -1;
}
auto dfs = [&](auto self,int node,int d) -> void {
if(d == len - 1){
x[-node - 1] = -1;
y[-node - 1] = -1;
}else{
x[-node - 1] = cnt--;
self(self,cnt + 1,d + 1);
y[-node - 1] = cnt--;
self(self,cnt + 1,d + 1);
}
};
auto dfs2 = [&](auto self,int node,int d) -> void {
if(d == len - 1){
ord.push_back(node);
}else{
if(!mrk[node]){
self(self,-x[node] - 1,d + 1);
}else{
self(self,-y[node] - 1,d + 1);
}
mrk[node]^=1;
}
};
dfs(dfs,-1,0);
for(int i = 0;i < (1<<len);i++){
dfs2(dfs2,0,0);
ord2.push_back(i);
}
sort(ord2.begin(),ord2.end(),[&](int a,int b){
return ord[a] < ord[b];
});
for(int i = 0;i < n;i++){
ord3.push_back(i);
}
sort(ord3.begin(),ord3.end(),[&](int a,int b){
return ord2[a] < ord2[b];
});
for(int i = 0;i < n;i++){
int id = ord[ord2[ord3[i]]];
if(x[id] == -1){
x[id] = a[i];
}else{
y[id] = a[i];
}
}
y[ord[ord2[(1<<len) - 1]]] = 0;
return answer(c,x,y);
}
/**
5 4
1 2 3 1
**/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
58 ms |
7336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
58 ms |
7336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
58 ms |
7336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
56 ms |
7112 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
57 ms |
7112 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
57 ms |
7112 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |