#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
#define scd(t) scanf("%d", &t)
#define sclld(t) scanf("%lld", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;
int curr = 0;
vi X, Y;
vii rec(int x, int l, int r) {
int id = curr + x;
while(int(X.size()) <= id) {
X.pb(0);
Y.pb(0);
}
if(l+1 >= r) {
vii out;
out.pb(mp(curr + x, 0));
out.pb(mp(curr + x, 1));
return out;
}
X[x+curr] = -(2*x + curr + 1);
Y[x+curr] = - (2 * x + 1 + curr + 1);
int mid = (l+r)/2;
vii v1 = rec(2*x, l, mid);
vii v2 = rec(2*x+1, mid+1, r);
vii out;
frange(i, (int)v1.size()) {
out.pb(v1[i]);
out.pb(v2[i]);
}
return out;
}
void create_circuit(int m, std::vector<int> A) {
int n = A.size();
vi C(m + 1);
vi cnt(m+1);
vvi nex(m+1);
cnt[0]++;
nex[0].pb(A[0]);
frange(i, n) {
cnt[A[i]]++;
if(i != n-1) {
nex[A[i]].pb(A[i+1]);
}
else nex[A[i]].pb(0);
}
frange(i, m+1) {
if(cnt[i] == 0) {
C[i] = 0;
continue;
}
int v = 1;
while(v < cnt[i]) v *= 2;
if(v == 1) {
C[i] = nex[i][0];
}
else {
curr = X.size() - 1;
C[i] = -(curr + 2);
vii out = rec(1, 0, v-1);
frange(j, v - cnt[i]) {
pii p = out[j];
if(p.s == 0) {
X[p.f] = C[i];
}
else {
Y[p.f] = C[i];
}
}
frange(j, cnt[i]) {
pii p = out[j+(v-cnt[i])];
if(p.s == 0) {
X[p.f] = nex[i][j];
}
else {
Y[p.f] = nex[i][j];
}
}
}
}
// frange(i, m+1) {
// printf("%d\n", C[i]);
// }
// frange(j, (int)X.size()) printf("%d %d\n", X[j], Y[j]);
answer(C, X, Y);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
19 ms |
7256 KB |
Output is correct |
3 |
Correct |
16 ms |
5980 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
8 ms |
4184 KB |
Output is correct |
6 |
Correct |
25 ms |
8796 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
19 ms |
7256 KB |
Output is correct |
3 |
Correct |
16 ms |
5980 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
8 ms |
4184 KB |
Output is correct |
6 |
Correct |
25 ms |
8796 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
35 ms |
8408 KB |
Output is correct |
9 |
Correct |
38 ms |
9944 KB |
Output is correct |
10 |
Correct |
73 ms |
13000 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
19 ms |
7256 KB |
Output is correct |
3 |
Correct |
16 ms |
5980 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
8 ms |
4184 KB |
Output is correct |
6 |
Correct |
25 ms |
8796 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
35 ms |
8408 KB |
Output is correct |
9 |
Correct |
38 ms |
9944 KB |
Output is correct |
10 |
Correct |
73 ms |
13000 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
72 ms |
12844 KB |
Output is correct |
15 |
Correct |
43 ms |
7004 KB |
Output is correct |
16 |
Correct |
58 ms |
10504 KB |
Output is correct |
17 |
Correct |
0 ms |
500 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 |
12480 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 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 |
40 ms |
5944 KB |
Output is correct |
3 |
Partially correct |
73 ms |
10688 KB |
Output is partially correct |
4 |
Partially correct |
78 ms |
11316 KB |
Output is partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
Output is partially correct |
2 |
Correct |
40 ms |
5944 KB |
Output is correct |
3 |
Partially correct |
73 ms |
10688 KB |
Output is partially correct |
4 |
Partially correct |
78 ms |
11316 KB |
Output is partially correct |
5 |
Partially correct |
86 ms |
13820 KB |
Output is partially correct |
6 |
Partially correct |
107 ms |
14952 KB |
Output is partially correct |
7 |
Partially correct |
99 ms |
14604 KB |
Output is partially correct |
8 |
Partially correct |
98 ms |
15768 KB |
Output is partially correct |
9 |
Partially correct |
74 ms |
11368 KB |
Output is partially correct |
10 |
Partially correct |
104 ms |
14792 KB |
Output is partially correct |
11 |
Partially correct |
110 ms |
16500 KB |
Output is partially correct |
12 |
Partially correct |
67 ms |
10668 KB |
Output is partially correct |
13 |
Partially correct |
61 ms |
9908 KB |
Output is partially correct |
14 |
Partially correct |
69 ms |
9908 KB |
Output is partially correct |
15 |
Partially correct |
65 ms |
9140 KB |
Output is partially correct |
16 |
Partially correct |
2 ms |
604 KB |
Output is partially correct |
17 |
Partially correct |
54 ms |
8704 KB |
Output is partially correct |
18 |
Partially correct |
54 ms |
8584 KB |
Output is partially correct |
19 |
Partially correct |
61 ms |
9220 KB |
Output is partially correct |
20 |
Partially correct |
77 ms |
11880 KB |
Output is partially correct |
21 |
Partially correct |
90 ms |
14136 KB |
Output is partially correct |
22 |
Partially correct |
76 ms |
11184 KB |
Output is partially correct |