#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int nax = 2e5+50;
int n,cnt,at;
vector<int> x,y,a;
bool g[nax];
void dfs(int cur){
if((at == a.size() - 1 && g[0] == 0) || at == a.size())
return;
int u = -cur;
u--;
if(x[u] == 0){
x[u] = a[at];
at++;
dfs(-1);
}else if(y[u] == 0){
y[u] = a[at];
at++;
dfs(-1);
}else if(g[u] == 0){
g[u] = 1;
dfs(x[u]);
}else if(g[u] == 1){
g[u] = 0;
dfs(y[u]);
}
}
void create_circuit(int M, vector<int> A) {
a = A;
a.push_back(0);
a.push_back(0);
n = a.size();
if(n == 3){
answer({1,0},{},{});
return;
}
for(int k=0;k<30;k++){
if((1<<k) >= n){
cnt = (1<<k)-1;
break;
}
}
x.resize(cnt,0);
y.resize(cnt,0);
for(int i=0;i<cnt/2;i++){
x[i] = -((i+1)*2);
y[i] = -((i+1)*2+1);
}
vector<int> C(M+1,-1);
dfs(-1);
for(int i=0;i<cnt;i++){
if(x[i] == 0){
x[i] = -1;
}
if(y[i] == 0){
y[i] = -1;
}
if(i == cnt-1)
y[i] = 0;
}
answer(C, x, y);
}
Compilation message
doll.cpp: In function 'void dfs(int)':
doll.cpp:16:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
16 | if((at == a.size() - 1 && g[0] == 0) || at == a.size())
| ~~~^~~~~~~~~~~~~~~
doll.cpp:16:46: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
16 | if((at == a.size() - 1 && g[0] == 0) || at == a.size())
| ~~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
204 KB |
Output is partially correct |
2 |
Partially correct |
97 ms |
8128 KB |
Output is partially correct |
3 |
Partially correct |
107 ms |
8160 KB |
Output is partially correct |
4 |
Partially correct |
123 ms |
8876 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
204 KB |
Output is partially correct |
2 |
Partially correct |
97 ms |
8128 KB |
Output is partially correct |
3 |
Partially correct |
107 ms |
8160 KB |
Output is partially correct |
4 |
Partially correct |
123 ms |
8876 KB |
Output is partially correct |
5 |
Partially correct |
147 ms |
9980 KB |
Output is partially correct |
6 |
Partially correct |
123 ms |
9688 KB |
Output is partially correct |
7 |
Partially correct |
129 ms |
9780 KB |
Output is partially correct |
8 |
Partially correct |
170 ms |
9364 KB |
Output is partially correct |
9 |
Partially correct |
97 ms |
8124 KB |
Output is partially correct |
10 |
Partially correct |
177 ms |
9368 KB |
Output is partially correct |
11 |
Partially correct |
120 ms |
8988 KB |
Output is partially correct |
12 |
Partially correct |
99 ms |
8352 KB |
Output is partially correct |
13 |
Partially correct |
99 ms |
8832 KB |
Output is partially correct |
14 |
Partially correct |
106 ms |
8904 KB |
Output is partially correct |
15 |
Partially correct |
112 ms |
9088 KB |
Output is partially correct |
16 |
Partially correct |
4 ms |
572 KB |
Output is partially correct |
17 |
Incorrect |
98 ms |
8380 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |