#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXM = 100005;
vector<int> nxt[MAXM];
int S = -1;
vector<int> C, X, Y;
int bindec(string bin) {
reverse(bin.begin(), bin.end());
int dec = 0;
for (auto c : bin) {
dec *= 2;
dec += c-'0';
}
//cout << bin << "-> " << dec << endl;
return dec;
}
void build(int rt, int i, int s, int e, string rec) {
if (s > e) return;
//cout << "BUILD " << rt << ' ' << i << ' ' << s << ' ' << e << " : " << rec << endl;
if (s == e) {
if (i == rt) {
C[i] = nxt[rt][bindec(rec)];
}
else {
X[-i] = rt;
Y[-i] = nxt[rt][bindec(rec)];
//X.push_back(rt);
//Y.push_back(nxt[rt][bindec(rec)]);
}
}
else if (s+1 == e && i != rt) {
X[-i] = nxt[rt][bindec(rec+'0')];
Y[-i] = nxt[rt][bindec(rec+'1')];
//X.push_back(nxt[rt][bindec(rec+'0')]);
//Y.push_back(nxt[rt][bindec(rec+'1')]);
}
else {
int m = (s+e)/2;
if (i >= 0) {
C[i] = S--;
build(rt, C[i], s, e, rec);
}
else {
int l = S;
build(rt, S--, s, m, rec+'0');
int r = S;
build(rt, S--, m+1, e, rec+'1');
//X.push_back(l);
//Y.push_back(r);
X[-i] = l;
Y[-i] = r;
//cout << "BRANCH " << i << " " << X[-i] << " " << Y[-i] << endl;
}
}
}
void create_circuit(int M, std::vector<int> A) {
int N = A.size();
C.resize(M+1);
A.push_back(0);
for (int i = 0; i <= N; ++i) {
nxt[A[i]].push_back(A[(i+1)%(N+1)]);
}
X.resize(2*N);
Y.resize(2*N);
for (int i = 0; i <= M; ++i) {
build(i, i, 0, (int)nxt[i].size()-1, "");
//cout << i << ": "; for (auto x : nxt[i]) cout << x << ' '; cout << endl;
}
vector<int> XX, YY;
for (int i = 1; i < -S; ++i) {
XX.push_back(X[i]);
YY.push_back(Y[i]);
}
//cout << endl;
//for (auto x : C) cout << x << ' '; cout << endl;
//for (auto x : XX) cout << x << ' '; cout << endl;
//for (auto x : YY) cout << x << ' '; cout << endl;
answer(C, XX, YY);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
35 ms |
7432 KB |
Output is correct |
3 |
Correct |
38 ms |
7092 KB |
Output is correct |
4 |
Correct |
4 ms |
2636 KB |
Output is correct |
5 |
Correct |
17 ms |
3788 KB |
Output is correct |
6 |
Correct |
46 ms |
9488 KB |
Output is correct |
7 |
Correct |
3 ms |
2636 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
35 ms |
7432 KB |
Output is correct |
3 |
Correct |
38 ms |
7092 KB |
Output is correct |
4 |
Correct |
4 ms |
2636 KB |
Output is correct |
5 |
Correct |
17 ms |
3788 KB |
Output is correct |
6 |
Correct |
46 ms |
9488 KB |
Output is correct |
7 |
Correct |
3 ms |
2636 KB |
Output is correct |
8 |
Correct |
77 ms |
10824 KB |
Output is correct |
9 |
Correct |
78 ms |
11216 KB |
Output is correct |
10 |
Correct |
132 ms |
15468 KB |
Output is correct |
11 |
Correct |
3 ms |
2636 KB |
Output is correct |
12 |
Correct |
3 ms |
2636 KB |
Output is correct |
13 |
Correct |
2 ms |
2636 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
35 ms |
7432 KB |
Output is correct |
3 |
Correct |
38 ms |
7092 KB |
Output is correct |
4 |
Correct |
4 ms |
2636 KB |
Output is correct |
5 |
Correct |
17 ms |
3788 KB |
Output is correct |
6 |
Correct |
46 ms |
9488 KB |
Output is correct |
7 |
Correct |
3 ms |
2636 KB |
Output is correct |
8 |
Correct |
77 ms |
10824 KB |
Output is correct |
9 |
Correct |
78 ms |
11216 KB |
Output is correct |
10 |
Correct |
132 ms |
15468 KB |
Output is correct |
11 |
Correct |
3 ms |
2636 KB |
Output is correct |
12 |
Correct |
3 ms |
2636 KB |
Output is correct |
13 |
Correct |
2 ms |
2636 KB |
Output is correct |
14 |
Incorrect |
114 ms |
15572 KB |
wrong motion |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
2636 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
2636 KB |
state 'Y' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
2636 KB |
state 'Y' |
2 |
Halted |
0 ms |
0 KB |
- |