#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void create_circuit(int m, std::vector<int> a) {
int p = 0;
a.push_back (0);
vector < vector < int > > adj (m + 1);
for (auto &x : a) adj[p].push_back (x), p = x;
vector < int > c (m + 1), x, y;
x.reserve (a.size () * 2);
y.reserve (a.size () * 2);
for (int i = 0; i <= m; ++i)
{
if (adj[i].empty ()) continue;
if (adj[i].size () == 1)
{
c[i] = adj[i][0];
continue;
}
int vt = 1, vtt = 0;
while (vt < adj[i].size ()) vt *= 2, ++vtt;
vector < int > v (vt, -(x.size () + 1));
for (int j = 0; j < adj[i].size (); ++j)
{
int k = j, q = 0;
for (int p = 0; p < vtt; ++p) q = q * 2 + k % 2, k /= 2;
v[q] = adj[i][j];
}
auto f = [&] (auto &self, int &p, int l, int r) -> void
{
if (l + 1 == r) p = v[l];
else
{
int m = (l + r) / 2;
x.push_back (0), y.push_back (0);
p = -x.size ();
self (self, x.back (), l, m);
self (self, y.back (), m, r);
}
};
f (f, c[i], 0, vt);
}
answer (c, x, y);
}
Compilation message
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:23:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | while (vt < adj[i].size ()) vt *= 2, ++vtt;
| ~~~^~~~~~~~~~~~~~~~
doll.cpp:25:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
25 | for (int j = 0; j < adj[i].size (); ++j)
| ~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
19 ms |
6996 KB |
Output is correct |
3 |
Correct |
16 ms |
5720 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
9 ms |
3932 KB |
Output is correct |
6 |
Correct |
25 ms |
8404 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
19 ms |
6996 KB |
Output is correct |
3 |
Correct |
16 ms |
5720 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
9 ms |
3932 KB |
Output is correct |
6 |
Correct |
25 ms |
8404 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
41 ms |
8272 KB |
Output is correct |
9 |
Correct |
36 ms |
9512 KB |
Output is correct |
10 |
Correct |
51 ms |
12352 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
19 ms |
6996 KB |
Output is correct |
3 |
Correct |
16 ms |
5720 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
9 ms |
3932 KB |
Output is correct |
6 |
Correct |
25 ms |
8404 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
41 ms |
8272 KB |
Output is correct |
9 |
Correct |
36 ms |
9512 KB |
Output is correct |
10 |
Correct |
51 ms |
12352 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Incorrect |
62 ms |
12356 KB |
wrong motion |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |