#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
vector<int> X, Y;
int build(vector<int> &nxt)
{
if (nxt.size() < 2)
return 0;
if (nxt.size() == 2)
{
X.push_back(nxt[0]);
Y.push_back(nxt[1]);
return -X.size();
}
int i = X.size();
X.push_back(0);
Y.push_back(0);
reverse(nxt.begin(), nxt.end());
while (__builtin_popcount(nxt.size()) != 1)
nxt.push_back(-1-i);
reverse(nxt.begin(), nxt.end());
vector<int> l, r;
for (int i = 0; i < nxt.size(); i += 2)
{
l.push_back(nxt[i]);
r.push_back(nxt[i+1]);
}
X[i] = build(l);
Y[i] = build(r);
return -1-i;
}
void create_circuit(int M, vector<int> A)
{
vector<vector<int>> nxt(M + 1, vector<int>());
vector<int> root(M + 1);
int N = A.size();
nxt[0].push_back(A[0]);
for (int i = 0; i < N - 1; i++)
nxt[A[i]].push_back(A[i+1]);
nxt[A[N-1]].push_back(0);
vector<int> C(M + 1);
for (int i = 0; i <= M; i++)
if (nxt[i].size() == 1)
C[i] = nxt[i][0];
else
C[i] = build(nxt[i]);
answer(C, X, Y);
}
Compilation message
doll.cpp: In function 'int build(std::vector<int>&)':
doll.cpp:28:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | for (int i = 0; i < nxt.size(); i += 2)
| ~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
20 ms |
7252 KB |
Output is correct |
3 |
Correct |
17 ms |
5844 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
8 ms |
4180 KB |
Output is correct |
6 |
Correct |
24 ms |
8788 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 |
20 ms |
7252 KB |
Output is correct |
3 |
Correct |
17 ms |
5844 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
8 ms |
4180 KB |
Output is correct |
6 |
Correct |
24 ms |
8788 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
33 ms |
8392 KB |
Output is correct |
9 |
Correct |
35 ms |
9936 KB |
Output is correct |
10 |
Correct |
65 ms |
12836 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 |
20 ms |
7252 KB |
Output is correct |
3 |
Correct |
17 ms |
5844 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
8 ms |
4180 KB |
Output is correct |
6 |
Correct |
24 ms |
8788 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
33 ms |
8392 KB |
Output is correct |
9 |
Correct |
35 ms |
9936 KB |
Output is correct |
10 |
Correct |
65 ms |
12836 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 |
77 ms |
12672 KB |
Output is correct |
15 |
Correct |
37 ms |
6856 KB |
Output is correct |
16 |
Correct |
55 ms |
10268 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
61 ms |
12472 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 |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
336 KB |
Output is partially correct |
2 |
Correct |
41 ms |
6732 KB |
Output is correct |
3 |
Partially correct |
73 ms |
11488 KB |
Output is partially correct |
4 |
Partially correct |
81 ms |
12272 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
336 KB |
Output is partially correct |
2 |
Correct |
41 ms |
6732 KB |
Output is correct |
3 |
Partially correct |
73 ms |
11488 KB |
Output is partially correct |
4 |
Partially correct |
81 ms |
12272 KB |
Output is partially correct |
5 |
Partially correct |
86 ms |
13312 KB |
Output is partially correct |
6 |
Partially correct |
95 ms |
14988 KB |
Output is partially correct |
7 |
Partially correct |
93 ms |
14668 KB |
Output is partially correct |
8 |
Partially correct |
99 ms |
15516 KB |
Output is partially correct |
9 |
Partially correct |
77 ms |
11268 KB |
Output is partially correct |
10 |
Partially correct |
107 ms |
15500 KB |
Output is partially correct |
11 |
Partially correct |
110 ms |
16140 KB |
Output is partially correct |
12 |
Partially correct |
70 ms |
10532 KB |
Output is partially correct |
13 |
Partially correct |
62 ms |
9912 KB |
Output is partially correct |
14 |
Partially correct |
59 ms |
9564 KB |
Output is partially correct |
15 |
Partially correct |
56 ms |
9136 KB |
Output is partially correct |
16 |
Partially correct |
2 ms |
596 KB |
Output is partially correct |
17 |
Partially correct |
55 ms |
8496 KB |
Output is partially correct |
18 |
Partially correct |
61 ms |
8588 KB |
Output is partially correct |
19 |
Partially correct |
60 ms |
9124 KB |
Output is partially correct |
20 |
Partially correct |
77 ms |
11856 KB |
Output is partially correct |
21 |
Partially correct |
95 ms |
13932 KB |
Output is partially correct |
22 |
Partially correct |
74 ms |
10976 KB |
Output is partially correct |