#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
int pw2[32];
vector<int> nxt[100005], c, x, y;
int seat = -1;
int dfs(int val, int lv, int mlv, int head)
{
if (lv == mlv)
{
if (nxt[head][val] == -1)
return -seat;
return nxt[head][val];
}
pair<int, int> ret;
ret.f = dfs(val, lv + 1, mlv, head);
ret.s = dfs(val + pw2[lv], lv + 1, mlv, head);
if (lv)
{
if (ret.f == ret.s)
return ret.f;
x.pb(ret.f);
y.pb(ret.s);
return -sz(x);
}
else
{
x[seat - 1] = ret.f;
y[seat - 1] = ret.s;
return -seat;
}
}
void create_circuit(int m, vector<int> a)
{
int n = sz(a);
pw2[0] = 1;
for (int i = 1; i < 32; i++)
pw2[i] = pw2[i - 1] * 2;
nxt[0].pb(a[0]);
for (int i = 0; i < n - 1; i++)
nxt[a[i]].pb(a[i + 1]);
nxt[a[n - 1]].pb(0);
c.pb(nxt[0][0]);
for (int i = 1; i <= m; i++)
{
if (nxt[i].empty())
{
c.pb(i);
continue;
}
if (sz(nxt[i]) == 1)
{
c.pb(nxt[i][0]);
continue;
}
int mlv = ceil(log2(sz(nxt[i])));
int msz = pw2[mlv];
vector<int> temp;
for (int j = 0; j < msz - sz(nxt[i]); j++)
temp.pb(-1);
for (auto val : nxt[i])
temp.pb(val);
nxt[i] = temp;
x.pb(-1);
y.pb(-1);
seat = sz(x);
c.pb(dfs(0, 0, mlv, i));
}
answer(c, x, y);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
31 ms |
6812 KB |
Output is correct |
3 |
Correct |
26 ms |
6400 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
13 ms |
4096 KB |
Output is correct |
6 |
Correct |
30 ms |
8128 KB |
Output is correct |
7 |
Correct |
2 ms |
2648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
31 ms |
6812 KB |
Output is correct |
3 |
Correct |
26 ms |
6400 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
13 ms |
4096 KB |
Output is correct |
6 |
Correct |
30 ms |
8128 KB |
Output is correct |
7 |
Correct |
2 ms |
2648 KB |
Output is correct |
8 |
Correct |
50 ms |
9068 KB |
Output is correct |
9 |
Correct |
80 ms |
9236 KB |
Output is correct |
10 |
Correct |
89 ms |
11680 KB |
Output is correct |
11 |
Correct |
2 ms |
2644 KB |
Output is correct |
12 |
Correct |
2 ms |
2772 KB |
Output is correct |
13 |
Correct |
2 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
31 ms |
6812 KB |
Output is correct |
3 |
Correct |
26 ms |
6400 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
13 ms |
4096 KB |
Output is correct |
6 |
Correct |
30 ms |
8128 KB |
Output is correct |
7 |
Correct |
2 ms |
2648 KB |
Output is correct |
8 |
Correct |
50 ms |
9068 KB |
Output is correct |
9 |
Correct |
80 ms |
9236 KB |
Output is correct |
10 |
Correct |
89 ms |
11680 KB |
Output is correct |
11 |
Correct |
2 ms |
2644 KB |
Output is correct |
12 |
Correct |
2 ms |
2772 KB |
Output is correct |
13 |
Correct |
2 ms |
2644 KB |
Output is correct |
14 |
Correct |
94 ms |
13372 KB |
Output is correct |
15 |
Correct |
53 ms |
8040 KB |
Output is correct |
16 |
Correct |
68 ms |
10860 KB |
Output is correct |
17 |
Correct |
2 ms |
2644 KB |
Output is correct |
18 |
Correct |
2 ms |
2644 KB |
Output is correct |
19 |
Correct |
2 ms |
2652 KB |
Output is correct |
20 |
Correct |
82 ms |
12340 KB |
Output is correct |
21 |
Correct |
2 ms |
2644 KB |
Output is correct |
22 |
Correct |
2 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2644 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
2 ms |
2644 KB |
Output is partially correct |
2 |
Correct |
23 ms |
5312 KB |
Output is correct |
3 |
Partially correct |
68 ms |
13300 KB |
Output is partially correct |
4 |
Correct |
59 ms |
11472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
2 ms |
2644 KB |
Output is partially correct |
2 |
Correct |
23 ms |
5312 KB |
Output is correct |
3 |
Partially correct |
68 ms |
13300 KB |
Output is partially correct |
4 |
Correct |
59 ms |
11472 KB |
Output is correct |
5 |
Partially correct |
108 ms |
15468 KB |
Output is partially correct |
6 |
Partially correct |
102 ms |
16556 KB |
Output is partially correct |
7 |
Partially correct |
126 ms |
16156 KB |
Output is partially correct |
8 |
Partially correct |
116 ms |
17172 KB |
Output is partially correct |
9 |
Partially correct |
77 ms |
11688 KB |
Output is partially correct |
10 |
Partially correct |
105 ms |
18040 KB |
Output is partially correct |
11 |
Partially correct |
95 ms |
17648 KB |
Output is partially correct |
12 |
Partially correct |
88 ms |
12328 KB |
Output is partially correct |
13 |
Partially correct |
94 ms |
11652 KB |
Output is partially correct |
14 |
Partially correct |
72 ms |
11316 KB |
Output is partially correct |
15 |
Partially correct |
67 ms |
11076 KB |
Output is partially correct |
16 |
Partially correct |
4 ms |
2900 KB |
Output is partially correct |
17 |
Partially correct |
71 ms |
10420 KB |
Output is partially correct |
18 |
Partially correct |
60 ms |
10432 KB |
Output is partially correct |
19 |
Partially correct |
73 ms |
10972 KB |
Output is partially correct |
20 |
Partially correct |
109 ms |
13376 KB |
Output is partially correct |
21 |
Partially correct |
99 ms |
15688 KB |
Output is partially correct |
22 |
Partially correct |
84 ms |
12756 KB |
Output is partially correct |