#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
void dfs(vector<int> adjlist, vector<int>& x, vector<int>& y)
{
//adjlist.size() > 1, insert new switch
if(adjlist.size()%2 == 1)
{
adjlist.insert(adjlist.begin(), -(x.size()+1));
}
if(adjlist.size()%2 == 0)
{
x.push_back(0);
y.push_back(0);
int index = x.size()-1;
if(adjlist.size() == 2)
{
x.back() = adjlist[0];
y.back() = adjlist[1];
return;
}
vector<int> even(0);
vector<int> odd(0);
for(int i = 0; i < (int) adjlist.size(); i++)
{
if(i%2 == 0)
{
even.push_back(adjlist[i]);
}
else
{
odd.push_back(adjlist[i]);
}
}
x[index] = -(x.size()+1);
dfs(even, x, y);
y[index] = -(x.size()+1);
dfs(odd, x, y);
return;
}
/*//Uneven size of adjlist?
int index = x.size();
x.push_back(0);
y.push_back(0);
x.back() = -(x.size()+1);
y.back() = -(x.size()+2);
x.push_back(adjlist[0]);
y.push_back(adjlist[1]);
x.push_back(-(index+1));
y.push_back(adjlist[2]);*/
}
void create_circuit(int m, std::vector<int> a)
{
int n = a.size();
vector<vector<int>> adjlist(m+1, vector<int> (0));
adjlist[0] = {a[0]};
for(int i = 0; i < n-1; i++)
{
adjlist[a[i]].push_back(a[i+1]);
}
adjlist[a[n-1]].push_back(0);
vector<int> c(m+1, 0);
vector<int> x(0);
vector<int> y(0);
for(int i = 0; i <= m; i++)
{
if(adjlist[i].empty())
{
continue;
}
if(adjlist[i].size() == 1)
{
c[i] = adjlist[i][0];
continue;
}
c[i] = -(x.size()+1);
dfs(adjlist[i], x, y);
}
assert(x.size() <= 2*a.size());
answer(c, x, y);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
29 ms |
6356 KB |
Output is correct |
3 |
Correct |
16 ms |
5144 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
11 ms |
3796 KB |
Output is correct |
6 |
Correct |
26 ms |
7636 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
29 ms |
6356 KB |
Output is correct |
3 |
Correct |
16 ms |
5144 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
11 ms |
3796 KB |
Output is correct |
6 |
Correct |
26 ms |
7636 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
32 ms |
7248 KB |
Output is correct |
9 |
Correct |
35 ms |
8656 KB |
Output is correct |
10 |
Correct |
50 ms |
11072 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
29 ms |
6356 KB |
Output is correct |
3 |
Correct |
16 ms |
5144 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
11 ms |
3796 KB |
Output is correct |
6 |
Correct |
26 ms |
7636 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
32 ms |
7248 KB |
Output is correct |
9 |
Correct |
35 ms |
8656 KB |
Output is correct |
10 |
Correct |
50 ms |
11072 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
91 ms |
10948 KB |
Output is correct |
15 |
Correct |
44 ms |
5800 KB |
Output is correct |
16 |
Correct |
58 ms |
8648 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
72 ms |
10668 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
2 |
Correct |
52 ms |
5496 KB |
Output is correct |
3 |
Partially correct |
79 ms |
10800 KB |
Output is partially correct |
4 |
Partially correct |
93 ms |
10660 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
2 |
Correct |
52 ms |
5496 KB |
Output is correct |
3 |
Partially correct |
79 ms |
10800 KB |
Output is partially correct |
4 |
Partially correct |
93 ms |
10660 KB |
Output is partially correct |
5 |
Partially correct |
100 ms |
12064 KB |
Output is partially correct |
6 |
Partially correct |
108 ms |
12492 KB |
Output is partially correct |
7 |
Partially correct |
107 ms |
12408 KB |
Output is partially correct |
8 |
Partially correct |
118 ms |
12856 KB |
Output is partially correct |
9 |
Partially correct |
77 ms |
8912 KB |
Output is partially correct |
10 |
Partially correct |
146 ms |
12712 KB |
Output is partially correct |
11 |
Partially correct |
117 ms |
13220 KB |
Output is partially correct |
12 |
Partially correct |
75 ms |
8804 KB |
Output is partially correct |
13 |
Partially correct |
83 ms |
8440 KB |
Output is partially correct |
14 |
Partially correct |
79 ms |
8252 KB |
Output is partially correct |
15 |
Partially correct |
61 ms |
7992 KB |
Output is partially correct |
16 |
Partially correct |
2 ms |
468 KB |
Output is partially correct |
17 |
Partially correct |
62 ms |
7176 KB |
Output is partially correct |
18 |
Partially correct |
60 ms |
7224 KB |
Output is partially correct |
19 |
Partially correct |
67 ms |
7608 KB |
Output is partially correct |
20 |
Partially correct |
109 ms |
9852 KB |
Output is partially correct |
21 |
Partially correct |
120 ms |
11512 KB |
Output is partially correct |
22 |
Partially correct |
80 ms |
9144 KB |
Output is partially correct |