#include <bits/stdc++.h>
#include "doll.h"
/// #pragma GCC optimize ("Ofast")
/// #pragma GCC target ("avx2")
/// #pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ld = long double;
using ii = pair<ll, ll>;
using vi = vector<int>;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lb lower_bound
const int MOD = 1e9 + 7;
vector<pair<int, int>> res; int D = 1;
int R[500005];
int solve(vector<int> V, int N) {
bool ok = 1;
for(int l = 1; l < V.size(); l++)
ok &= (V[l] == V[l - 1]);
if(ok) return V[0];
int v = D++, i = 0, k = res.size();
vector<int> X, Y; res.push_back({-1, -1});
while(i < V.size()) {
X.push_back(V[i++]);
Y.push_back(V[i++]);
}
res[k] = {solve(X, N / 2), solve(Y, N / 2)};
return -v;
}
void create_circuit(int M, vector<int> A) {
A.push_back(0); int N = A.size(), S = 1, K = 0;
while(S < N) S *= 2, K++;
vector<int> B(S, 0);
for(int l = 0; l < S; l++) {
R[l] = ((R[l >> 1] >> 1) | ((l & 1) << (K - 1)));
if(l < S - N) B[R[l]] = -1;
}
int i = 0;
for(int l = 0; l < S; l++) {
if(B[l] == -1) continue;
B[l] = A[i++];
}
solve(B, S); vector<int> C, X, Y;
for(int l = 0; l <= M; l++)
C.push_back(-1);
for(int l = 0; l < res.size(); l++)
X.push_back(res[l].ff),
Y.push_back(res[l].ss);
answer(C, X, Y);
}
Compilation message
doll.cpp: In function 'int solve(std::vector<int>, int)':
doll.cpp:26:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | for(int l = 1; l < V.size(); l++)
| ~~^~~~~~~~~~
doll.cpp:31:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | while(i < V.size()) {
| ~~^~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:54:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | for(int l = 0; l < res.size(); l++)
| ~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
42 ms |
6500 KB |
Output is correct |
3 |
Correct |
39 ms |
5680 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
9 ms |
1612 KB |
Output is correct |
6 |
Correct |
59 ms |
8432 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
42 ms |
6500 KB |
Output is correct |
3 |
Correct |
39 ms |
5680 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
9 ms |
1612 KB |
Output is correct |
6 |
Correct |
59 ms |
8432 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
81 ms |
10560 KB |
Output is correct |
9 |
Correct |
76 ms |
10512 KB |
Output is correct |
10 |
Correct |
106 ms |
14184 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
42 ms |
6500 KB |
Output is correct |
3 |
Correct |
39 ms |
5680 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
9 ms |
1612 KB |
Output is correct |
6 |
Correct |
59 ms |
8432 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
81 ms |
10560 KB |
Output is correct |
9 |
Correct |
76 ms |
10512 KB |
Output is correct |
10 |
Correct |
106 ms |
14184 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
103 ms |
13980 KB |
Output is correct |
15 |
Correct |
74 ms |
10476 KB |
Output is correct |
16 |
Correct |
113 ms |
13200 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
103 ms |
13960 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
21 ms |
8528 KB |
Output is correct |
3 |
Correct |
19 ms |
8564 KB |
Output is correct |
4 |
Correct |
26 ms |
9156 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
21 ms |
8528 KB |
Output is correct |
3 |
Correct |
19 ms |
8564 KB |
Output is correct |
4 |
Correct |
26 ms |
9156 KB |
Output is correct |
5 |
Correct |
102 ms |
13260 KB |
Output is correct |
6 |
Correct |
100 ms |
15232 KB |
Output is correct |
7 |
Correct |
106 ms |
15260 KB |
Output is correct |
8 |
Correct |
99 ms |
14356 KB |
Output is correct |
9 |
Correct |
54 ms |
10696 KB |
Output is correct |
10 |
Correct |
97 ms |
12820 KB |
Output is correct |
11 |
Correct |
98 ms |
14032 KB |
Output is correct |
12 |
Correct |
66 ms |
10952 KB |
Output is correct |
13 |
Correct |
71 ms |
11404 KB |
Output is correct |
14 |
Correct |
69 ms |
11452 KB |
Output is correct |
15 |
Correct |
71 ms |
11404 KB |
Output is correct |
16 |
Correct |
3 ms |
596 KB |
Output is correct |
17 |
Correct |
62 ms |
8800 KB |
Output is correct |
18 |
Correct |
66 ms |
10952 KB |
Output is correct |
19 |
Correct |
66 ms |
10932 KB |
Output is correct |
20 |
Correct |
101 ms |
14992 KB |
Output is correct |
21 |
Correct |
100 ms |
14000 KB |
Output is correct |
22 |
Correct |
100 ms |
14080 KB |
Output is correct |