# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1067998 | 2024-08-21T06:32:13 Z | Ignut | 자동 인형 (IOI18_doll) | C++17 | 96 ms | 16264 KB |
// Ignut #include <bits/stdc++.h> using namespace std; using ll = long long; void answer(vector<int> C, vector<int> X, vector<int> Y); vector<int> X, Y; int nextSwitch = -1; int sz; vector<int> leaves; int Build(int lvl) { int v = nextSwitch --; if ((1 << lvl) >= sz) { leaves.push_back(v); return v; } X[-v - 1] = Build(lvl + 1); Y[-v - 1] = Build(lvl + 1); return v; } void create_circuit(int M, vector<int> A) { int N = A.size(); vector<int> edges[M + 1]; edges[0].push_back(A[0]); for (int i = 0; i + 1 < N; i ++) edges[A[i]].push_back(A[i + 1]); edges[A.back()].push_back(0); vector<int> C(M + 1); for (int i = 0; i <= M; i ++) { if (edges[i].empty()) { C[i] = i; continue; } if (edges[i].size() == 1) { C[i] = edges[i][0]; continue; } // vector<int> sw; // for (int j = 0; j < edges[i].size() - 1; j ++) { // sw.push_back(nextSwitch --); // } // C[i] = sw.front(); // for (int j = 0; j < sw.size(); j ++) { // X.push_back(edges[i][j]); // if (j + 1 == sw.size()) // Y.push_back(edges[i][j + 1]); // else // Y.push_back(sw[j + 1]); // } sz = edges[i].size(); int len; for (int cnt = 1; cnt <= 30; cnt ++) { int pw = 1 << cnt; if (pw >= sz) { for (int j = 0; j < pw - 1; j ++) { // cerr << "+\n"; X.push_back(nextSwitch); Y.push_back(nextSwitch); } len = cnt; break; } } int root = nextSwitch; C[i] = nextSwitch; leaves.clear(); Build(1); auto ReverseBits = [&len](int x) -> int { int res = 0; for (int i = 0; i < len; i ++) { res <<= 1; if (x & 1) res |= 1; x >>= 1; } return res; }; vector<int> e; while (e.size() + edges[i].size() < 2 * leaves.size()) e.push_back(root); for (int val : edges[i]) e.push_back(val); for (int j = 0; j < leaves.size(); j ++) { // cerr << i << '\n'; // cerr << i << " -> " << ReverseBits(i) << '\n'; int left = ReverseBits(j * 2); int right = ReverseBits(j * 2 + 1); if (left < e.size()) X[-leaves[j] - 1] = e[left]; if (right < e.size()) Y[-leaves[j] - 1] = e[right]; } } answer(C, X, Y); return; } /* 4 4 1 2 1 3 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 30 ms | 6792 KB | Output is correct |
3 | Correct | 17 ms | 5720 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 7 ms | 3932 KB | Output is correct |
6 | Correct | 25 ms | 8536 KB | Output is correct |
7 | Correct | 0 ms | 344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 30 ms | 6792 KB | Output is correct |
3 | Correct | 17 ms | 5720 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 7 ms | 3932 KB | Output is correct |
6 | Correct | 25 ms | 8536 KB | Output is correct |
7 | Correct | 0 ms | 344 KB | Output is correct |
8 | Correct | 37 ms | 8128 KB | Output is correct |
9 | Correct | 36 ms | 9680 KB | Output is correct |
10 | Correct | 64 ms | 12464 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 604 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 30 ms | 6792 KB | Output is correct |
3 | Correct | 17 ms | 5720 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 7 ms | 3932 KB | Output is correct |
6 | Correct | 25 ms | 8536 KB | Output is correct |
7 | Correct | 0 ms | 344 KB | Output is correct |
8 | Correct | 37 ms | 8128 KB | Output is correct |
9 | Correct | 36 ms | 9680 KB | Output is correct |
10 | Correct | 64 ms | 12464 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 604 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 62 ms | 13128 KB | Output is correct |
15 | Correct | 36 ms | 6908 KB | Output is correct |
16 | Correct | 61 ms | 10372 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 344 KB | Output is correct |
20 | Correct | 63 ms | 12500 KB | Output is correct |
21 | Correct | 1 ms | 344 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Partially correct | 0 ms | 348 KB | Output is partially correct |
2 | Correct | 31 ms | 6600 KB | Output is correct |
3 | Partially correct | 90 ms | 11484 KB | Output is partially correct |
4 | Partially correct | 51 ms | 12220 KB | Output is partially correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Partially correct | 0 ms | 348 KB | Output is partially correct |
2 | Correct | 31 ms | 6600 KB | Output is correct |
3 | Partially correct | 90 ms | 11484 KB | Output is partially correct |
4 | Partially correct | 51 ms | 12220 KB | Output is partially correct |
5 | Partially correct | 68 ms | 14704 KB | Output is partially correct |
6 | Partially correct | 71 ms | 15476 KB | Output is partially correct |
7 | Partially correct | 96 ms | 15360 KB | Output is partially correct |
8 | Partially correct | 69 ms | 15896 KB | Output is partially correct |
9 | Partially correct | 52 ms | 10512 KB | Output is partially correct |
10 | Partially correct | 68 ms | 15992 KB | Output is partially correct |
11 | Partially correct | 70 ms | 16264 KB | Output is partially correct |
12 | Partially correct | 52 ms | 10744 KB | Output is partially correct |
13 | Partially correct | 45 ms | 10268 KB | Output is partially correct |
14 | Partially correct | 79 ms | 10056 KB | Output is partially correct |
15 | Partially correct | 47 ms | 9716 KB | Output is partially correct |
16 | Partially correct | 1 ms | 600 KB | Output is partially correct |
17 | Partially correct | 37 ms | 8520 KB | Output is partially correct |
18 | Partially correct | 36 ms | 8516 KB | Output is partially correct |
19 | Partially correct | 53 ms | 9132 KB | Output is partially correct |
20 | Partially correct | 52 ms | 11760 KB | Output is partially correct |
21 | Partially correct | 85 ms | 14144 KB | Output is partially correct |
22 | Partially correct | 50 ms | 10980 KB | Output is partially correct |