#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, -((int) x.size () + 1));
for (int j = 0; j < adj[i].size (); ++j)
{
int k = j, q = 0;
if (adj[i][j] == 0) k = vt - 1;
for (int p = 0; p < vtt; ++p) q = q * 2 + k % 2, k /= 2;
v[q] = adj[i][j];
}
auto f = [&] (auto &self, int l, int r) -> int
{
if (l + 1 == r) return v[l];
int m = (l + r) / 2;
x.push_back (0), y.push_back (0);
int i = x.size () - 1;
x[i] = self (self, l, m);
y[i] = self (self, m, r);
return -(i + 1);
};
c[i] = f (f, 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)
| ~~^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
21 ms |
6784 KB |
Output is correct |
3 |
Correct |
16 ms |
5720 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
10 ms |
3932 KB |
Output is correct |
6 |
Correct |
26 ms |
8400 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
21 ms |
6784 KB |
Output is correct |
3 |
Correct |
16 ms |
5720 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
10 ms |
3932 KB |
Output is correct |
6 |
Correct |
26 ms |
8400 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
34 ms |
8024 KB |
Output is correct |
9 |
Correct |
35 ms |
9304 KB |
Output is correct |
10 |
Correct |
53 ms |
11852 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
21 ms |
6784 KB |
Output is correct |
3 |
Correct |
16 ms |
5720 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
10 ms |
3932 KB |
Output is correct |
6 |
Correct |
26 ms |
8400 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
34 ms |
8024 KB |
Output is correct |
9 |
Correct |
35 ms |
9304 KB |
Output is correct |
10 |
Correct |
53 ms |
11852 KB |
Output is correct |
11 |
Correct |
1 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 |
66 ms |
11936 KB |
state 'Y' |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
state 'Y' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
Output is partially correct |
2 |
Correct |
31 ms |
6312 KB |
Output is correct |
3 |
Partially correct |
50 ms |
8908 KB |
Output is partially correct |
4 |
Partially correct |
62 ms |
10312 KB |
Output is partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
Output is partially correct |
2 |
Correct |
31 ms |
6312 KB |
Output is correct |
3 |
Partially correct |
50 ms |
8908 KB |
Output is partially correct |
4 |
Partially correct |
62 ms |
10312 KB |
Output is partially correct |
5 |
Incorrect |
74 ms |
13680 KB |
state 'Y' |
6 |
Halted |
0 ms |
0 KB |
- |