#ifdef NYAOWO
#include "grader.cpp"
#endif
#include "doll.h"
#include <bits/stdc++.h>
#define For(i, a, b) for(int i = a; i <= b; i++)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) ((int)x.size())
#define eb emplace_back
using namespace std;
using LL = long long;
using pii = pair<int, int>;
const int MAXM = 100010;
vector<int> x, y;
int solve(vector<int> &v, int l, int r) {
if(l == r) return v[l];
int m = (l + r) / 2;
int id = sz(x);
x.eb(0); y.eb(0);
int a = solve(v, m + 1, r);
int b = solve(v, l, m);
x[id] = a; y[id] = b;
// cout << l << " " << r << " " << id << " " << x[id] << " " << y[id] << " " << (-(id + 1)) << "\n" << flush;
return -(id + 1);
}
void rev(int n, vector<int> &v) {
int j = 0;
For(i, 0, n - 1) {
if(i < j) swap(v[i], v[j]);
for(int k = n >> 1; (j ^= k) < k; k >>= 1);
}
}
void create_circuit(int M, std::vector<int> A) {
// if(M == 1) {
// solve2(sz(A));
// return;
// }
A.eb(0);
vector<int> ans(M + 1, -1);
reverse(all(A));
ans[0] = A.back();
A.pop_back();
int lgn = __lg(sz(A) - 1) + 1;
int n = (1 << lgn);
vector<int> b(n);
For(i, 0, n - 1) b[i] = i;
rev(n, b);
b.erase(b.begin() + sz(A), b.end());
sort(all(b));
vector<int> c(n, -1);
For(i, 0, sz(A) - 1) {
c[b[i]] = A[i];
}
rev(n, c);
solve(c, 0, n - 1);
answer(ans, x, y);
}
/*
4 16
1 2 1 3 1 3 1 1 2 1 3 1 3 1 4 4
1 13
1 1 1 1 1 1 1 1 1 1 1 1 1
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
2 |
Correct |
43 ms |
6436 KB |
Output is correct |
3 |
Partially correct |
70 ms |
9712 KB |
Output is partially correct |
4 |
Partially correct |
95 ms |
10320 KB |
Output is partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
2 |
Correct |
43 ms |
6436 KB |
Output is correct |
3 |
Partially correct |
70 ms |
9712 KB |
Output is partially correct |
4 |
Partially correct |
95 ms |
10320 KB |
Output is partially correct |
5 |
Partially correct |
85 ms |
10488 KB |
Output is partially correct |
6 |
Partially correct |
90 ms |
10416 KB |
Output is partially correct |
7 |
Partially correct |
83 ms |
10564 KB |
Output is partially correct |
8 |
Partially correct |
84 ms |
10408 KB |
Output is partially correct |
9 |
Partially correct |
69 ms |
9572 KB |
Output is partially correct |
10 |
Partially correct |
82 ms |
10476 KB |
Output is partially correct |
11 |
Partially correct |
95 ms |
10444 KB |
Output is partially correct |
12 |
Partially correct |
71 ms |
9704 KB |
Output is partially correct |
13 |
Correct |
49 ms |
6976 KB |
Output is correct |
14 |
Partially correct |
74 ms |
9688 KB |
Output is partially correct |
15 |
Partially correct |
76 ms |
9876 KB |
Output is partially correct |
16 |
Partially correct |
3 ms |
596 KB |
Output is partially correct |
17 |
Correct |
54 ms |
6596 KB |
Output is correct |
18 |
Correct |
44 ms |
6580 KB |
Output is correct |
19 |
Partially correct |
74 ms |
9676 KB |
Output is partially correct |
20 |
Partially correct |
88 ms |
10396 KB |
Output is partially correct |
21 |
Partially correct |
83 ms |
10428 KB |
Output is partially correct |
22 |
Partially correct |
97 ms |
10428 KB |
Output is partially correct |