#include <bits/stdc++.h>
using namespace std;
//#define int long long
//#define pii pair<long long, long long>
void answer(vector<signed> C, vector<signed> X, vector<signed> Y);
void create_circuit(int k, vector<int> a) {
int n = a.size();
a.push_back(0);
vector<vector<int>> g(k + 1);
g[0].push_back(a[0]);
for (int i = 0; i < n; i++) {
g[a[i]].push_back(a[i + 1]);
}
vector<int> C(k + 1), X, Y;
C[0] = g[0][0];
for (int j = 1; j < k + 1; j++) {
int cnt = g[j].size();
int z = 1, ord = 0;
while (z < cnt) {
z *= 2;
ord++;
}
if (ord == 0) {
if (cnt == 1) C[j] = g[j][0];
continue;
}
vector<int> p(z);
p[0] = 0;
for (int i = 0; i < ord; i++) {
for (int ni = 0; ni < (1 << i); ni++) {
p[(1 << i) + ni] = p[ni] + (1 << (ord - i - 1));
}
}
int wnots = X.size();
C[j] = -wnots - 1;
vector<int> v(z, -1);
for (int i = z - (int) g[j].size(); i < z; i++) {
v[i] = g[j][i - z + (int) g[j].size()];
}
vector<int> vp(z);
for (int i = 0; i < z; i++) {
vp[p[i]] = v[i];
}
vector<int> X_(z), Y_(z);
for (int ni = 1; ni < z / 2; ni++) {
X_[ni] = -ni * 2 - wnots;
Y_[ni] = -ni * 2 - 1 - wnots;
}
for (int ni = 0; ni < z / 2; ni++) {
X_[ni + z / 2] = vp[ni * 2];
Y_[ni + z / 2] = vp[ni * 2 + 1];
}
for (int i = 1; i < z; i++) {
X.push_back(X_[i]);
Y.push_back(Y_[i]);
}
}
answer(C, X, Y);
}
#ifdef ONLINE_JUDGE
void answer(vector<signed> C, vector<signed> X, vector<signed> Y) {
for (int x : C) cout << x << " ";
cout << "\n";
for (int x : X) cout << x << " ";
cout << "\n";
for (int x : Y) cout << x << " ";
cout << "\n";
}
int main() {
create_circuit(4, {1, 1, 1, 1, 1, 1});
}
#endif
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
15 ms |
6484 KB |
Output is correct |
3 |
Correct |
13 ms |
5132 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
5 ms |
3932 KB |
Output is correct |
6 |
Correct |
23 ms |
7636 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
15 ms |
6484 KB |
Output is correct |
3 |
Correct |
13 ms |
5132 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
5 ms |
3932 KB |
Output is correct |
6 |
Correct |
23 ms |
7636 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
32 ms |
7308 KB |
Output is correct |
9 |
Correct |
27 ms |
8536 KB |
Output is correct |
10 |
Correct |
47 ms |
11340 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
15 ms |
6484 KB |
Output is correct |
3 |
Correct |
13 ms |
5132 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
5 ms |
3932 KB |
Output is correct |
6 |
Correct |
23 ms |
7636 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
32 ms |
7308 KB |
Output is correct |
9 |
Correct |
27 ms |
8536 KB |
Output is correct |
10 |
Correct |
47 ms |
11340 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Incorrect |
48 ms |
11076 KB |
wrong motion |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
Output is partially correct |
2 |
Correct |
20 ms |
6332 KB |
Output is correct |
3 |
Partially correct |
43 ms |
9436 KB |
Output is partially correct |
4 |
Partially correct |
46 ms |
11340 KB |
Output is partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
Output is partially correct |
2 |
Correct |
20 ms |
6332 KB |
Output is correct |
3 |
Partially correct |
43 ms |
9436 KB |
Output is partially correct |
4 |
Partially correct |
46 ms |
11340 KB |
Output is partially correct |
5 |
Incorrect |
54 ms |
12096 KB |
wrong motion |
6 |
Halted |
0 ms |
0 KB |
- |