#include <bits/stdc++.h>
#include "doll.h"
using namespace std;
const int N = 2e5 + 10;
int n , m;
vector <int> C , X , Y , adj[N];
int Rev(int x , int cnt)
{
int res = 0;
for(int i = 0 ; i < cnt ; i++) if((x >> i) & 1)
res |= (1 << (cnt - i - 1));
return res;
}
int Solve(vector <int> vec , bool flg = true)
{
if(vec.size() == 1)
return vec[0];
X.push_back(0);
Y.push_back(0);
int now = X.size();
vector <int> v[2];
if(flg)
{
int tmp = 1 , cnt = 0;
while(tmp < vec.size())
{
tmp *= 2;
cnt++;
}
vector <int> fake(tmp , 0);
for(int i = 0 ; i < tmp - vec.size() ; i++)
fake[Rev(i , cnt)] = -now;
int pos = 0;
for(int i = 0 ; i < tmp ; i++) if(fake[i] != -now)
{
fake[i] = vec[pos];
pos++;
}
vec = fake;
}
bool eq = true;
for(int i = 1 ; i < vec.size() ; i++) if(vec[i] != vec[0])
eq = false;
if(eq)
{
X[now - 1] = vec[0];
Y[now - 1] = vec[0];
return -now;
}
for(int i = 0 ; i < vec.size() ; i++)
v[i % 2].push_back(vec[i]);
int tmp = Solve(v[0] , 0);
X[now - 1] = tmp;
tmp = Solve(v[1] , 0);
Y[now - 1] = tmp;
return -1 * now;
}
void Build(int v)
{
if(adj[v].empty())
{
C[v] = 0;
return;
}
int tmp = Solve(adj[v]);
C[v] = tmp;
}
void create_circuit(int mm , vector <int> A)
{
n = A.size();
m = mm;
C.resize(m + 1);
adj[0].push_back(A[0]);
for(int i = 0 ; i + 1 < n ; i++)
adj[A[i]].push_back(A[i + 1]);
adj[A.back()].push_back(0);
for(int i = 0 ; i <= m ; i++)
{
Build(i);
}
answer(C , X , Y);
}
Compilation message
doll.cpp: In function 'int Solve(std::vector<int>, bool)':
doll.cpp:29:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | while(tmp < vec.size())
| ~~~~^~~~~~~~~~~~
doll.cpp:35:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | for(int i = 0 ; i < tmp - vec.size() ; i++)
| ~~^~~~~~~~~~~~~~~~~~
doll.cpp:46:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | for(int i = 1 ; i < vec.size() ; i++) if(vec[i] != vec[0])
| ~~^~~~~~~~~~~~
doll.cpp:54:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | for(int i = 0 ; i < vec.size() ; i++)
| ~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4956 KB |
Output is correct |
2 |
Correct |
18 ms |
9560 KB |
Output is correct |
3 |
Correct |
14 ms |
8792 KB |
Output is correct |
4 |
Correct |
2 ms |
4952 KB |
Output is correct |
5 |
Correct |
11 ms |
6488 KB |
Output is correct |
6 |
Correct |
23 ms |
10832 KB |
Output is correct |
7 |
Correct |
2 ms |
4952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4956 KB |
Output is correct |
2 |
Correct |
18 ms |
9560 KB |
Output is correct |
3 |
Correct |
14 ms |
8792 KB |
Output is correct |
4 |
Correct |
2 ms |
4952 KB |
Output is correct |
5 |
Correct |
11 ms |
6488 KB |
Output is correct |
6 |
Correct |
23 ms |
10832 KB |
Output is correct |
7 |
Correct |
2 ms |
4952 KB |
Output is correct |
8 |
Correct |
37 ms |
11644 KB |
Output is correct |
9 |
Correct |
35 ms |
11980 KB |
Output is correct |
10 |
Correct |
52 ms |
14876 KB |
Output is correct |
11 |
Correct |
2 ms |
4956 KB |
Output is correct |
12 |
Correct |
2 ms |
4956 KB |
Output is correct |
13 |
Correct |
2 ms |
5088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4956 KB |
Output is correct |
2 |
Correct |
18 ms |
9560 KB |
Output is correct |
3 |
Correct |
14 ms |
8792 KB |
Output is correct |
4 |
Correct |
2 ms |
4952 KB |
Output is correct |
5 |
Correct |
11 ms |
6488 KB |
Output is correct |
6 |
Correct |
23 ms |
10832 KB |
Output is correct |
7 |
Correct |
2 ms |
4952 KB |
Output is correct |
8 |
Correct |
37 ms |
11644 KB |
Output is correct |
9 |
Correct |
35 ms |
11980 KB |
Output is correct |
10 |
Correct |
52 ms |
14876 KB |
Output is correct |
11 |
Correct |
2 ms |
4956 KB |
Output is correct |
12 |
Correct |
2 ms |
4956 KB |
Output is correct |
13 |
Correct |
2 ms |
5088 KB |
Output is correct |
14 |
Correct |
69 ms |
16524 KB |
Output is correct |
15 |
Correct |
37 ms |
10936 KB |
Output is correct |
16 |
Correct |
56 ms |
14100 KB |
Output is correct |
17 |
Correct |
2 ms |
4956 KB |
Output is correct |
18 |
Correct |
2 ms |
4956 KB |
Output is correct |
19 |
Correct |
2 ms |
4956 KB |
Output is correct |
20 |
Correct |
60 ms |
15516 KB |
Output is correct |
21 |
Correct |
2 ms |
4956 KB |
Output is correct |
22 |
Correct |
2 ms |
4956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
4952 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4956 KB |
Output is correct |
2 |
Correct |
15 ms |
9472 KB |
Output is correct |
3 |
Correct |
25 ms |
11468 KB |
Output is correct |
4 |
Correct |
27 ms |
12916 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4956 KB |
Output is correct |
2 |
Correct |
15 ms |
9472 KB |
Output is correct |
3 |
Correct |
25 ms |
11468 KB |
Output is correct |
4 |
Correct |
27 ms |
12916 KB |
Output is correct |
5 |
Partially correct |
84 ms |
18456 KB |
Output is partially correct |
6 |
Partially correct |
85 ms |
18200 KB |
Output is partially correct |
7 |
Partially correct |
86 ms |
18404 KB |
Output is partially correct |
8 |
Partially correct |
82 ms |
17264 KB |
Output is partially correct |
9 |
Correct |
56 ms |
12036 KB |
Output is correct |
10 |
Partially correct |
89 ms |
15600 KB |
Output is partially correct |
11 |
Partially correct |
68 ms |
15040 KB |
Output is partially correct |
12 |
Partially correct |
53 ms |
11632 KB |
Output is partially correct |
13 |
Partially correct |
54 ms |
13556 KB |
Output is partially correct |
14 |
Partially correct |
54 ms |
13564 KB |
Output is partially correct |
15 |
Partially correct |
69 ms |
13844 KB |
Output is partially correct |
16 |
Partially correct |
4 ms |
5208 KB |
Output is partially correct |
17 |
Partially correct |
59 ms |
11224 KB |
Output is partially correct |
18 |
Partially correct |
54 ms |
11288 KB |
Output is partially correct |
19 |
Partially correct |
45 ms |
11452 KB |
Output is partially correct |
20 |
Partially correct |
65 ms |
14740 KB |
Output is partially correct |
21 |
Partially correct |
66 ms |
14628 KB |
Output is partially correct |
22 |
Partially correct |
63 ms |
14292 KB |
Output is partially correct |