#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);
}
answer(c, x, y);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
23 ms |
6696 KB |
Output is correct |
3 |
Correct |
17 ms |
5460 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
10 ms |
3796 KB |
Output is correct |
6 |
Correct |
34 ms |
7944 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 |
23 ms |
6696 KB |
Output is correct |
3 |
Correct |
17 ms |
5460 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
10 ms |
3796 KB |
Output is correct |
6 |
Correct |
34 ms |
7944 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
33 ms |
7496 KB |
Output is correct |
9 |
Correct |
35 ms |
8912 KB |
Output is correct |
10 |
Correct |
52 ms |
11456 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
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 |
23 ms |
6696 KB |
Output is correct |
3 |
Correct |
17 ms |
5460 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
10 ms |
3796 KB |
Output is correct |
6 |
Correct |
34 ms |
7944 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
33 ms |
7496 KB |
Output is correct |
9 |
Correct |
35 ms |
8912 KB |
Output is correct |
10 |
Correct |
52 ms |
11456 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
92 ms |
11320 KB |
Output is correct |
15 |
Correct |
36 ms |
6080 KB |
Output is correct |
16 |
Correct |
66 ms |
9108 KB |
Output is correct |
17 |
Correct |
1 ms |
296 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
66 ms |
10948 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
2 |
Correct |
42 ms |
5816 KB |
Output is correct |
3 |
Partially correct |
99 ms |
11032 KB |
Output is partially correct |
4 |
Partially correct |
95 ms |
10816 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
2 |
Correct |
42 ms |
5816 KB |
Output is correct |
3 |
Partially correct |
99 ms |
11032 KB |
Output is partially correct |
4 |
Partially correct |
95 ms |
10816 KB |
Output is partially correct |
5 |
Partially correct |
95 ms |
12264 KB |
Output is partially correct |
6 |
Partially correct |
102 ms |
12720 KB |
Output is partially correct |
7 |
Partially correct |
97 ms |
12532 KB |
Output is partially correct |
8 |
Partially correct |
106 ms |
13112 KB |
Output is partially correct |
9 |
Partially correct |
77 ms |
9128 KB |
Output is partially correct |
10 |
Partially correct |
112 ms |
12960 KB |
Output is partially correct |
11 |
Partially correct |
119 ms |
13392 KB |
Output is partially correct |
12 |
Partially correct |
78 ms |
9008 KB |
Output is partially correct |
13 |
Partially correct |
66 ms |
8616 KB |
Output is partially correct |
14 |
Partially correct |
64 ms |
8436 KB |
Output is partially correct |
15 |
Partially correct |
58 ms |
8248 KB |
Output is partially correct |
16 |
Partially correct |
2 ms |
596 KB |
Output is partially correct |
17 |
Partially correct |
59 ms |
7424 KB |
Output is partially correct |
18 |
Partially correct |
61 ms |
7416 KB |
Output is partially correct |
19 |
Partially correct |
64 ms |
7828 KB |
Output is partially correct |
20 |
Partially correct |
85 ms |
9960 KB |
Output is partially correct |
21 |
Partially correct |
101 ms |
11828 KB |
Output is partially correct |
22 |
Partially correct |
80 ms |
9388 KB |
Output is partially correct |