#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();
vector <int> v[2];
/*cout << now << " solve: " << endl;
for(auto u : vec)
cout << u << " " ;
cout << endl;*/
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;
}
for(int i = 0 ; i < vec.size() ; i++)
{
if(vec[i] < 0)
{
if(v[0].size() * 2 != vec.size())
v[0].push_back(vec[i]);
else
v[1].push_back(vec[i]);
continue;
}
if(v[0].size() > v[1].size())
v[1].push_back(vec[i]);
else
v[0].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);
}
/*for(int i = 0 ; i <= m ; i++)
cout << i << " -> " << C[i] << endl;
for(int i = 0 ; i < X.size() ; i++)
cout << -(i + 1) << " : " << X[i] << " " << Y[i] << endl;*/
answer(C , X , Y);
}
Compilation message
doll.cpp: In function 'int Solve(std::vector<int>, bool)':
doll.cpp:25:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
25 | while(tmp < vec.size())
| ~~~~^~~~~~~~~~~~
doll.cpp:28:34: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
28 | while(vec.size() + fake.size() < tmp)
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
doll.cpp:40:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | for(int i = 0 ; i < vec.size() ; i++)
| ~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4952 KB |
Output is correct |
2 |
Correct |
18 ms |
8792 KB |
Output is correct |
3 |
Correct |
15 ms |
8284 KB |
Output is correct |
4 |
Correct |
3 ms |
4952 KB |
Output is correct |
5 |
Correct |
10 ms |
6236 KB |
Output is correct |
6 |
Correct |
23 ms |
10072 KB |
Output is correct |
7 |
Correct |
2 ms |
4956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4952 KB |
Output is correct |
2 |
Correct |
18 ms |
8792 KB |
Output is correct |
3 |
Correct |
15 ms |
8284 KB |
Output is correct |
4 |
Correct |
3 ms |
4952 KB |
Output is correct |
5 |
Correct |
10 ms |
6236 KB |
Output is correct |
6 |
Correct |
23 ms |
10072 KB |
Output is correct |
7 |
Correct |
2 ms |
4956 KB |
Output is correct |
8 |
Correct |
67 ms |
10692 KB |
Output is correct |
9 |
Correct |
69 ms |
11088 KB |
Output is correct |
10 |
Correct |
70 ms |
13508 KB |
Output is correct |
11 |
Correct |
3 ms |
4956 KB |
Output is correct |
12 |
Correct |
3 ms |
4956 KB |
Output is correct |
13 |
Correct |
1 ms |
4956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4952 KB |
Output is correct |
2 |
Correct |
18 ms |
8792 KB |
Output is correct |
3 |
Correct |
15 ms |
8284 KB |
Output is correct |
4 |
Correct |
3 ms |
4952 KB |
Output is correct |
5 |
Correct |
10 ms |
6236 KB |
Output is correct |
6 |
Correct |
23 ms |
10072 KB |
Output is correct |
7 |
Correct |
2 ms |
4956 KB |
Output is correct |
8 |
Correct |
67 ms |
10692 KB |
Output is correct |
9 |
Correct |
69 ms |
11088 KB |
Output is correct |
10 |
Correct |
70 ms |
13508 KB |
Output is correct |
11 |
Correct |
3 ms |
4956 KB |
Output is correct |
12 |
Correct |
3 ms |
4956 KB |
Output is correct |
13 |
Correct |
1 ms |
4956 KB |
Output is correct |
14 |
Correct |
81 ms |
14924 KB |
Output is correct |
15 |
Correct |
64 ms |
9916 KB |
Output is correct |
16 |
Correct |
76 ms |
12520 KB |
Output is correct |
17 |
Correct |
3 ms |
4956 KB |
Output is correct |
18 |
Correct |
2 ms |
4956 KB |
Output is correct |
19 |
Correct |
3 ms |
5208 KB |
Output is correct |
20 |
Correct |
86 ms |
14012 KB |
Output is correct |
21 |
Correct |
4 ms |
4956 KB |
Output is correct |
22 |
Correct |
3 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 |
4 ms |
4956 KB |
Output is partially correct |
2 |
Correct |
43 ms |
10816 KB |
Output is correct |
3 |
Partially correct |
63 ms |
13384 KB |
Output is partially correct |
4 |
Correct |
64 ms |
14428 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
4 ms |
4956 KB |
Output is partially correct |
2 |
Correct |
43 ms |
10816 KB |
Output is correct |
3 |
Partially correct |
63 ms |
13384 KB |
Output is partially correct |
4 |
Correct |
64 ms |
14428 KB |
Output is correct |
5 |
Partially correct |
93 ms |
17000 KB |
Output is partially correct |
6 |
Partially correct |
94 ms |
16924 KB |
Output is partially correct |
7 |
Partially correct |
114 ms |
16824 KB |
Output is partially correct |
8 |
Partially correct |
103 ms |
15964 KB |
Output is partially correct |
9 |
Partially correct |
52 ms |
11368 KB |
Output is partially correct |
10 |
Partially correct |
77 ms |
14180 KB |
Output is partially correct |
11 |
Partially correct |
64 ms |
13636 KB |
Output is partially correct |
12 |
Partially correct |
42 ms |
10748 KB |
Output is partially correct |
13 |
Partially correct |
56 ms |
12784 KB |
Output is partially correct |
14 |
Partially correct |
60 ms |
12804 KB |
Output is partially correct |
15 |
Partially correct |
55 ms |
12956 KB |
Output is partially correct |
16 |
Incorrect |
3 ms |
5460 KB |
wrong motion |
17 |
Halted |
0 ms |
0 KB |
- |