#include "doll.h"
#include<bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define int long long
const int inf = 1e18+10;
const int maxn = 2e5+10;
int n, m;
vector<int> g[maxn];
void create_circuit(int32_t M, std::vector<int32_t> A) {
// int N = A.size();
// std::vector<int> C(M + 1);
// C[0] = -1;
// for (int i = 1; i <= M; ++i) {
// C[i] = 1;
// }
// std::vector<int> X(N), Y(N);
// for (int k = 0; k < N; ++k) {
// X[k] = Y[k] = A[k];
// }
// answer(C, X, Y);
n = A.size();
m = M;
vector<int32_t> c(m+1),x,y;
for(int i = -1; i < n; i++) {
int u,v;
if(i == -1) u = 0, v = A[0];
else if(i == n-1) u = A[n-1], v = 0;
else u = A[i], v = A[i+1];
g[u].pb(v);
}
int cnt = 1;
for(int i = 0; i <= m; i++) {
if(g[i].size() == 0) {
c[i] = i;
continue;
}
if(g[i].size() == 1) {
c[i] = g[i][0];
continue;
}
vector<int> next = g[i];
vector<int> liga;
int mult = 1;
while(next.size() > 1) {
vector<int> newnext;
for(int i = 0; i < next.size()/2; i++) {
newnext.pb(cnt);
x.pb(mult*next[i]);
y.pb(mult*next[i+next.size()/2]);
cnt++;
}
if(next.size()%2 == 1) {
newnext.pb(cnt);
y.pb(mult*next.back());
x.pb(0);
liga.pb(cnt);
cnt++;
}
// while(next.size()) {
// newnext.pb(cnt);
// x.pb(mult*next.back());
// next.pop_back();
// y.pb(mult*next.back());
// next.pop_back();
// cnt++;
// }
mult = -1;
next = newnext;
}
for(auto v : liga) {
x[v-1] = -next[0];
}
c[i] = -next[0];
// cout << i << " " << c[i] << " " << cnt << endl;
}
// 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 'void create_circuit(int32_t, std::vector<int>)':
doll.cpp:57:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
57 | for(int i = 0; i < next.size()/2; i++) {
| ~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4948 KB |
Output is correct |
2 |
Correct |
19 ms |
8736 KB |
Output is correct |
3 |
Correct |
16 ms |
8336 KB |
Output is correct |
4 |
Correct |
2 ms |
4948 KB |
Output is correct |
5 |
Correct |
10 ms |
6100 KB |
Output is correct |
6 |
Correct |
26 ms |
10076 KB |
Output is correct |
7 |
Correct |
3 ms |
4948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4948 KB |
Output is correct |
2 |
Correct |
19 ms |
8736 KB |
Output is correct |
3 |
Correct |
16 ms |
8336 KB |
Output is correct |
4 |
Correct |
2 ms |
4948 KB |
Output is correct |
5 |
Correct |
10 ms |
6100 KB |
Output is correct |
6 |
Correct |
26 ms |
10076 KB |
Output is correct |
7 |
Correct |
3 ms |
4948 KB |
Output is correct |
8 |
Correct |
36 ms |
10320 KB |
Output is correct |
9 |
Correct |
36 ms |
10992 KB |
Output is correct |
10 |
Correct |
53 ms |
13440 KB |
Output is correct |
11 |
Correct |
2 ms |
4948 KB |
Output is correct |
12 |
Correct |
2 ms |
4948 KB |
Output is correct |
13 |
Correct |
2 ms |
4948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4948 KB |
Output is correct |
2 |
Correct |
19 ms |
8736 KB |
Output is correct |
3 |
Correct |
16 ms |
8336 KB |
Output is correct |
4 |
Correct |
2 ms |
4948 KB |
Output is correct |
5 |
Correct |
10 ms |
6100 KB |
Output is correct |
6 |
Correct |
26 ms |
10076 KB |
Output is correct |
7 |
Correct |
3 ms |
4948 KB |
Output is correct |
8 |
Correct |
36 ms |
10320 KB |
Output is correct |
9 |
Correct |
36 ms |
10992 KB |
Output is correct |
10 |
Correct |
53 ms |
13440 KB |
Output is correct |
11 |
Correct |
2 ms |
4948 KB |
Output is correct |
12 |
Correct |
2 ms |
4948 KB |
Output is correct |
13 |
Correct |
2 ms |
4948 KB |
Output is correct |
14 |
Correct |
79 ms |
15640 KB |
Output is correct |
15 |
Correct |
37 ms |
10504 KB |
Output is correct |
16 |
Correct |
56 ms |
14844 KB |
Output is correct |
17 |
Correct |
2 ms |
4948 KB |
Output is correct |
18 |
Correct |
2 ms |
5000 KB |
Output is correct |
19 |
Correct |
3 ms |
4972 KB |
Output is correct |
20 |
Correct |
63 ms |
15932 KB |
Output is correct |
21 |
Correct |
2 ms |
4880 KB |
Output is correct |
22 |
Correct |
3 ms |
4948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4948 KB |
Output is correct |
2 |
Correct |
2 ms |
4948 KB |
Output is correct |
3 |
Correct |
2 ms |
4948 KB |
Output is correct |
4 |
Correct |
2 ms |
5000 KB |
Output is correct |
5 |
Correct |
2 ms |
4948 KB |
Output is correct |
6 |
Correct |
2 ms |
4948 KB |
Output is correct |
7 |
Correct |
2 ms |
4948 KB |
Output is correct |
8 |
Correct |
3 ms |
4992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4948 KB |
Output is correct |
2 |
Correct |
38 ms |
11728 KB |
Output is correct |
3 |
Correct |
31 ms |
12864 KB |
Output is correct |
4 |
Correct |
51 ms |
14668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4948 KB |
Output is correct |
2 |
Correct |
38 ms |
11728 KB |
Output is correct |
3 |
Correct |
31 ms |
12864 KB |
Output is correct |
4 |
Correct |
51 ms |
14668 KB |
Output is correct |
5 |
Partially correct |
77 ms |
16312 KB |
Output is partially correct |
6 |
Partially correct |
69 ms |
17640 KB |
Output is partially correct |
7 |
Partially correct |
73 ms |
17540 KB |
Output is partially correct |
8 |
Partially correct |
92 ms |
17172 KB |
Output is partially correct |
9 |
Partially correct |
31 ms |
11596 KB |
Output is partially correct |
10 |
Partially correct |
56 ms |
15588 KB |
Output is partially correct |
11 |
Partially correct |
48 ms |
16472 KB |
Output is partially correct |
12 |
Partially correct |
45 ms |
12504 KB |
Output is partially correct |
13 |
Partially correct |
47 ms |
13196 KB |
Output is partially correct |
14 |
Partially correct |
70 ms |
13244 KB |
Output is partially correct |
15 |
Partially correct |
50 ms |
13284 KB |
Output is partially correct |
16 |
Partially correct |
5 ms |
5204 KB |
Output is partially correct |
17 |
Partially correct |
31 ms |
12100 KB |
Output is partially correct |
18 |
Partially correct |
32 ms |
11908 KB |
Output is partially correct |
19 |
Partially correct |
32 ms |
12224 KB |
Output is partially correct |
20 |
Partially correct |
55 ms |
15524 KB |
Output is partially correct |
21 |
Partially correct |
47 ms |
15896 KB |
Output is partially correct |
22 |
Partially correct |
50 ms |
15212 KB |
Output is partially correct |