#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 + 3)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
**/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
348 KB |
Output is partially correct |
2 |
Partially correct |
147 ms |
16524 KB |
Output is partially correct |
3 |
Partially correct |
154 ms |
16236 KB |
Output is partially correct |
4 |
Partially correct |
159 ms |
17256 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
348 KB |
Output is partially correct |
2 |
Partially correct |
147 ms |
16524 KB |
Output is partially correct |
3 |
Partially correct |
154 ms |
16236 KB |
Output is partially correct |
4 |
Partially correct |
159 ms |
17256 KB |
Output is partially correct |
5 |
Partially correct |
173 ms |
17544 KB |
Output is partially correct |
6 |
Partially correct |
167 ms |
17392 KB |
Output is partially correct |
7 |
Partially correct |
174 ms |
17800 KB |
Output is partially correct |
8 |
Partially correct |
164 ms |
17288 KB |
Output is partially correct |
9 |
Partially correct |
147 ms |
16148 KB |
Output is partially correct |
10 |
Partially correct |
164 ms |
17152 KB |
Output is partially correct |
11 |
Partially correct |
170 ms |
17208 KB |
Output is partially correct |
12 |
Partially correct |
153 ms |
16420 KB |
Output is partially correct |
13 |
Partially correct |
145 ms |
16828 KB |
Output is partially correct |
14 |
Partially correct |
147 ms |
16240 KB |
Output is partially correct |
15 |
Partially correct |
149 ms |
16200 KB |
Output is partially correct |
16 |
Partially correct |
3 ms |
1112 KB |
Output is partially correct |
17 |
Incorrect |
148 ms |
16492 KB |
wrong motion |
18 |
Halted |
0 ms |
0 KB |
- |