#include "doll.h"
#include<bits/stdc++.h>
#define M 200010
using namespace std;
vector <int> g[M];
int c[2*M], x[2*M], y[2*M];
int tp = 1;
void solve(int val, vector <int> &v){
tp = max(tp, val);
if(v.size() == 2){
x[val] = v[0];
y[val] = v[1];
return;
}
vector <int> a, b;
for(int i = 0;i < v.size();i++){
if(!(i % 2)) a.push_back(v[i]);
else b.push_back(v[i]);
}
if(a.size() % 2 != b.size() % 2){
int t = a.back();
a.pop_back();
b.push_back(t);
a.push_back(-val);
}
x[val] = -(val+1);
solve(val+1, a);
y[val] = -(tp+1);
solve(tp+1, b);
return;
}
void create_circuit(int m, std::vector<int> A) {
vector <int> a;
a.push_back(0);
for(auto x : A) a.push_back(x);
a.push_back(0);
for(int i = 0;i < (int) (a.size())-1;i++){
g[a[i]].push_back(a[i+1]);
}
for(int i = 0;i <= m;i++){
if(g[i].size() == 0){
c[i] = 0;
continue;
}
if(g[i].size() == 1){
c[i] = g[i][0];
continue;
}
c[i] = -tp;
solve(tp, g[i]);
tp++;
}
vector <int> cc, xx, yy;
for(int i = 0;i <= m;i++) cc.push_back(c[i]);
for(int i = 1;i < tp;i++){
xx.push_back(x[i]);
yy.push_back(y[i]);
}
// for(auto t : cc) cout << t << ' ';
// cout << endl;
// for(int i = 0;i < xx.size();i++){
// cout << xx[i] << ' ' << yy[i] << endl;
// }
answer(cc, xx, yy);
return;
}
Compilation message
doll.cpp: In function 'void solve(int, std::vector<int>&)':
doll.cpp:18:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | for(int i = 0;i < v.size();i++){
| ~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
7512 KB |
Output is correct |
2 |
Correct |
20 ms |
11608 KB |
Output is correct |
3 |
Correct |
16 ms |
11220 KB |
Output is correct |
4 |
Correct |
2 ms |
7516 KB |
Output is correct |
5 |
Correct |
9 ms |
8916 KB |
Output is correct |
6 |
Correct |
24 ms |
13144 KB |
Output is correct |
7 |
Correct |
2 ms |
7516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
7512 KB |
Output is correct |
2 |
Correct |
20 ms |
11608 KB |
Output is correct |
3 |
Correct |
16 ms |
11220 KB |
Output is correct |
4 |
Correct |
2 ms |
7516 KB |
Output is correct |
5 |
Correct |
9 ms |
8916 KB |
Output is correct |
6 |
Correct |
24 ms |
13144 KB |
Output is correct |
7 |
Correct |
2 ms |
7516 KB |
Output is correct |
8 |
Correct |
34 ms |
16072 KB |
Output is correct |
9 |
Correct |
47 ms |
16556 KB |
Output is correct |
10 |
Correct |
52 ms |
19368 KB |
Output is correct |
11 |
Correct |
2 ms |
9560 KB |
Output is correct |
12 |
Correct |
2 ms |
9560 KB |
Output is correct |
13 |
Correct |
2 ms |
9564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
7512 KB |
Output is correct |
2 |
Correct |
20 ms |
11608 KB |
Output is correct |
3 |
Correct |
16 ms |
11220 KB |
Output is correct |
4 |
Correct |
2 ms |
7516 KB |
Output is correct |
5 |
Correct |
9 ms |
8916 KB |
Output is correct |
6 |
Correct |
24 ms |
13144 KB |
Output is correct |
7 |
Correct |
2 ms |
7516 KB |
Output is correct |
8 |
Correct |
34 ms |
16072 KB |
Output is correct |
9 |
Correct |
47 ms |
16556 KB |
Output is correct |
10 |
Correct |
52 ms |
19368 KB |
Output is correct |
11 |
Correct |
2 ms |
9560 KB |
Output is correct |
12 |
Correct |
2 ms |
9560 KB |
Output is correct |
13 |
Correct |
2 ms |
9564 KB |
Output is correct |
14 |
Correct |
70 ms |
19776 KB |
Output is correct |
15 |
Correct |
38 ms |
15544 KB |
Output is correct |
16 |
Correct |
56 ms |
18380 KB |
Output is correct |
17 |
Correct |
2 ms |
9564 KB |
Output is correct |
18 |
Correct |
2 ms |
9564 KB |
Output is correct |
19 |
Correct |
2 ms |
9564 KB |
Output is correct |
20 |
Correct |
61 ms |
19268 KB |
Output is correct |
21 |
Correct |
2 ms |
9564 KB |
Output is correct |
22 |
Correct |
2 ms |
9564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
9564 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
2 ms |
9564 KB |
Output is partially correct |
2 |
Correct |
43 ms |
15808 KB |
Output is correct |
3 |
Partially correct |
74 ms |
18760 KB |
Output is partially correct |
4 |
Partially correct |
78 ms |
21324 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
2 ms |
9564 KB |
Output is partially correct |
2 |
Correct |
43 ms |
15808 KB |
Output is correct |
3 |
Partially correct |
74 ms |
18760 KB |
Output is partially correct |
4 |
Partially correct |
78 ms |
21324 KB |
Output is partially correct |
5 |
Partially correct |
84 ms |
23464 KB |
Output is partially correct |
6 |
Partially correct |
94 ms |
23804 KB |
Output is partially correct |
7 |
Partially correct |
94 ms |
23552 KB |
Output is partially correct |
8 |
Partially correct |
99 ms |
24236 KB |
Output is partially correct |
9 |
Partially correct |
74 ms |
20424 KB |
Output is partially correct |
10 |
Partially correct |
118 ms |
24280 KB |
Output is partially correct |
11 |
Partially correct |
104 ms |
24900 KB |
Output is partially correct |
12 |
Partially correct |
70 ms |
20168 KB |
Output is partially correct |
13 |
Partially correct |
63 ms |
19656 KB |
Output is partially correct |
14 |
Partially correct |
60 ms |
18700 KB |
Output is partially correct |
15 |
Partially correct |
58 ms |
18268 KB |
Output is partially correct |
16 |
Partially correct |
3 ms |
9820 KB |
Output is partially correct |
17 |
Partially correct |
61 ms |
17920 KB |
Output is partially correct |
18 |
Partially correct |
61 ms |
18120 KB |
Output is partially correct |
19 |
Partially correct |
60 ms |
18416 KB |
Output is partially correct |
20 |
Partially correct |
78 ms |
21932 KB |
Output is partially correct |
21 |
Partially correct |
96 ms |
23272 KB |
Output is partially correct |
22 |
Partially correct |
74 ms |
20724 KB |
Output is partially correct |