#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)
{
if(vec.size() == 1)
return vec[0];
X.push_back(0);
Y.push_back(0);
int now = X.size();
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]);
X[now - 1] = Solve(v[0]);
Y[now - 1] = Solve(v[1]);
return -now;
}
void Build(int v)
{
//cout << "WTF " << endl;
if(adj[v].empty())
{
C[v] = 0;
return;
}
/*cout << "HI " << endl;
cout << Solve(adj[v]) << endl;
cout << "WETRW RW REWE " << endl;*/
C[v] = Solve(adj[v]);
/*cout << C[v] << endl;
cout << "BYE " << endl;*/
}
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++)
{
//cout << i << " : " << endl;
Build(i);
}
answer(C , X , Y);
}
Compilation message
doll.cpp: In function 'int Solve(std::vector<int>)':
doll.cpp:23:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | for(int i = 0 ; i < vec.size() ; i++)
| ~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4952 KB |
Output is correct |
2 |
Correct |
18 ms |
8796 KB |
Output is correct |
3 |
Correct |
16 ms |
8308 KB |
Output is correct |
4 |
Correct |
2 ms |
4956 KB |
Output is correct |
5 |
Correct |
7 ms |
6236 KB |
Output is correct |
6 |
Correct |
20 ms |
10324 KB |
Output is correct |
7 |
Correct |
1 ms |
4956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4952 KB |
Output is correct |
2 |
Correct |
18 ms |
8796 KB |
Output is correct |
3 |
Correct |
16 ms |
8308 KB |
Output is correct |
4 |
Correct |
2 ms |
4956 KB |
Output is correct |
5 |
Correct |
7 ms |
6236 KB |
Output is correct |
6 |
Correct |
20 ms |
10324 KB |
Output is correct |
7 |
Correct |
1 ms |
4956 KB |
Output is correct |
8 |
Correct |
32 ms |
10528 KB |
Output is correct |
9 |
Correct |
33 ms |
11160 KB |
Output is correct |
10 |
Correct |
51 ms |
13436 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 |
4952 KB |
Output is correct |
2 |
Correct |
18 ms |
8796 KB |
Output is correct |
3 |
Correct |
16 ms |
8308 KB |
Output is correct |
4 |
Correct |
2 ms |
4956 KB |
Output is correct |
5 |
Correct |
7 ms |
6236 KB |
Output is correct |
6 |
Correct |
20 ms |
10324 KB |
Output is correct |
7 |
Correct |
1 ms |
4956 KB |
Output is correct |
8 |
Correct |
32 ms |
10528 KB |
Output is correct |
9 |
Correct |
33 ms |
11160 KB |
Output is correct |
10 |
Correct |
51 ms |
13436 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 |
73 ms |
14992 KB |
Output is correct |
15 |
Correct |
33 ms |
9924 KB |
Output is correct |
16 |
Correct |
55 ms |
12568 KB |
Output is correct |
17 |
Correct |
4 ms |
5056 KB |
Output is correct |
18 |
Correct |
3 ms |
4956 KB |
Output is correct |
19 |
Correct |
2 ms |
4956 KB |
Output is correct |
20 |
Correct |
60 ms |
14088 KB |
Output is correct |
21 |
Correct |
2 ms |
4960 KB |
Output is correct |
22 |
Correct |
2 ms |
4956 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 |
4964 KB |
Output is partially correct |
2 |
Correct |
43 ms |
10848 KB |
Output is correct |
3 |
Partially correct |
76 ms |
17360 KB |
Output is partially correct |
4 |
Partially correct |
72 ms |
15500 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
2 ms |
4964 KB |
Output is partially correct |
2 |
Correct |
43 ms |
10848 KB |
Output is correct |
3 |
Partially correct |
76 ms |
17360 KB |
Output is partially correct |
4 |
Partially correct |
72 ms |
15500 KB |
Output is partially correct |
5 |
Partially correct |
83 ms |
17040 KB |
Output is partially correct |
6 |
Partially correct |
97 ms |
18204 KB |
Output is partially correct |
7 |
Partially correct |
90 ms |
17736 KB |
Output is partially correct |
8 |
Partially correct |
95 ms |
18816 KB |
Output is partially correct |
9 |
Partially correct |
73 ms |
15068 KB |
Output is partially correct |
10 |
Partially correct |
115 ms |
18368 KB |
Output is partially correct |
11 |
Partially correct |
105 ms |
19352 KB |
Output is partially correct |
12 |
Partially correct |
67 ms |
14448 KB |
Output is partially correct |
13 |
Partially correct |
63 ms |
13756 KB |
Output is partially correct |
14 |
Partially correct |
58 ms |
13424 KB |
Output is partially correct |
15 |
Partially correct |
53 ms |
12836 KB |
Output is partially correct |
16 |
Partially correct |
3 ms |
5212 KB |
Output is partially correct |
17 |
Partially correct |
54 ms |
12488 KB |
Output is partially correct |
18 |
Partially correct |
56 ms |
12268 KB |
Output is partially correct |
19 |
Partially correct |
60 ms |
12820 KB |
Output is partially correct |
20 |
Partially correct |
77 ms |
15028 KB |
Output is partially correct |
21 |
Partially correct |
108 ms |
17216 KB |
Output is partially correct |
22 |
Partially correct |
74 ms |
14280 KB |
Output is partially correct |