#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 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();
if(flg)
{
int tmp = 1;
while(tmp < vec.size())
tmp *= 2;
vector <int> fake;
while(vec.size() + fake.size() < tmp)
fake.push_back(-now);
for(auto u : vec)
fake.push_back(u);
vec = fake;
}
if(vec[0] < 0 && vec.back() < 0)
{
X[now - 1] = vec[0];
Y[now - 1] = vec[0];
return -now;
}
vector <int> v[2];
if(vec.size() % 2 == 1)
{
vec.push_back(-now);
swap(vec[vec.size() - 1] , vec[vec.size() - 2]);
}
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:20:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | while(tmp < vec.size())
| ~~~~^~~~~~~~~~~~
doll.cpp:23:34: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
23 | while(vec.size() + fake.size() < tmp)
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
doll.cpp:41:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for(int i = 0 ; i < vec.size() ; i++)
| ~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4956 KB |
Output is correct |
2 |
Correct |
18 ms |
9240 KB |
Output is correct |
3 |
Correct |
20 ms |
8924 KB |
Output is correct |
4 |
Correct |
2 ms |
4956 KB |
Output is correct |
5 |
Correct |
7 ms |
6236 KB |
Output is correct |
6 |
Correct |
26 ms |
10784 KB |
Output is correct |
7 |
Correct |
2 ms |
4952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4956 KB |
Output is correct |
2 |
Correct |
18 ms |
9240 KB |
Output is correct |
3 |
Correct |
20 ms |
8924 KB |
Output is correct |
4 |
Correct |
2 ms |
4956 KB |
Output is correct |
5 |
Correct |
7 ms |
6236 KB |
Output is correct |
6 |
Correct |
26 ms |
10784 KB |
Output is correct |
7 |
Correct |
2 ms |
4952 KB |
Output is correct |
8 |
Correct |
37 ms |
11596 KB |
Output is correct |
9 |
Correct |
33 ms |
11984 KB |
Output is correct |
10 |
Correct |
72 ms |
15068 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 |
4956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4956 KB |
Output is correct |
2 |
Correct |
18 ms |
9240 KB |
Output is correct |
3 |
Correct |
20 ms |
8924 KB |
Output is correct |
4 |
Correct |
2 ms |
4956 KB |
Output is correct |
5 |
Correct |
7 ms |
6236 KB |
Output is correct |
6 |
Correct |
26 ms |
10784 KB |
Output is correct |
7 |
Correct |
2 ms |
4952 KB |
Output is correct |
8 |
Correct |
37 ms |
11596 KB |
Output is correct |
9 |
Correct |
33 ms |
11984 KB |
Output is correct |
10 |
Correct |
72 ms |
15068 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 |
4956 KB |
Output is correct |
14 |
Correct |
80 ms |
16528 KB |
Output is correct |
15 |
Correct |
37 ms |
10936 KB |
Output is correct |
16 |
Correct |
57 ms |
14104 KB |
Output is correct |
17 |
Correct |
2 ms |
4956 KB |
Output is correct |
18 |
Correct |
2 ms |
4956 KB |
Output is correct |
19 |
Correct |
1 ms |
4956 KB |
Output is correct |
20 |
Correct |
66 ms |
15400 KB |
Output is correct |
21 |
Correct |
2 ms |
4952 KB |
Output is correct |
22 |
Correct |
2 ms |
4952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4956 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
2 ms |
5128 KB |
Output is partially correct |
2 |
Correct |
51 ms |
11804 KB |
Output is correct |
3 |
Partially correct |
80 ms |
17468 KB |
Output is partially correct |
4 |
Partially correct |
92 ms |
18268 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
2 ms |
5128 KB |
Output is partially correct |
2 |
Correct |
51 ms |
11804 KB |
Output is correct |
3 |
Partially correct |
80 ms |
17468 KB |
Output is partially correct |
4 |
Partially correct |
92 ms |
18268 KB |
Output is partially correct |
5 |
Partially correct |
97 ms |
18656 KB |
Output is partially correct |
6 |
Partially correct |
98 ms |
19768 KB |
Output is partially correct |
7 |
Partially correct |
100 ms |
19192 KB |
Output is partially correct |
8 |
Partially correct |
122 ms |
20628 KB |
Output is partially correct |
9 |
Partially correct |
81 ms |
15732 KB |
Output is partially correct |
10 |
Partially correct |
113 ms |
19860 KB |
Output is partially correct |
11 |
Partially correct |
110 ms |
20864 KB |
Output is partially correct |
12 |
Partially correct |
70 ms |
15376 KB |
Output is partially correct |
13 |
Partially correct |
66 ms |
14604 KB |
Output is partially correct |
14 |
Partially correct |
66 ms |
14196 KB |
Output is partially correct |
15 |
Partially correct |
62 ms |
13768 KB |
Output is partially correct |
16 |
Partially correct |
5 ms |
5212 KB |
Output is partially correct |
17 |
Partially correct |
62 ms |
13168 KB |
Output is partially correct |
18 |
Partially correct |
61 ms |
13292 KB |
Output is partially correct |
19 |
Partially correct |
61 ms |
13836 KB |
Output is partially correct |
20 |
Partially correct |
79 ms |
16588 KB |
Output is partially correct |
21 |
Partially correct |
100 ms |
18752 KB |
Output is partially correct |
22 |
Partially correct |
73 ms |
15684 KB |
Output is partially correct |