#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define pct __builtin_popcount
vector<PII> ff(vector<int> a) {
int n = (int) a.size();
int p = 1;
while (p < n) p *= 2;
vector<PII> s(p-1);
vector<bool> t(p-1, 0);
for (int i = 0; i < p/2; i ++)
s[i] = mp(-(i*2+1 +1), -(i*2+2 +1));
for (int i = 0; i < p; i ++) {
int x = 0;
while (x < p-1) {
if (t[x] == 1) {
t[x] = 0;
x = x*2+2;
} else {
t[x] = 1;
x = x*2+1;
}
}
int ne = -1;
if (i >= p-n) ne = a[i-(p-n)];
if (x%2) s[(x-1)/2].fi = ne;
else s[(x-1)/2].se = ne;
}
return s;
}
void create_circuit(int m, vector<int> a) {
int n = a.size();
vector<int> sc(m + 1, -1);
sc[0] = a[0];
vector<vector<int> > p(m+1);
for (int i = 0; i < n; i ++) {
int ne = 0;
if (i != n-1) ne = a[i+1];
p[a[i]].pb(ne);
}
vector<int> sx, sy;
int nc = 0;
for (int i = 1; i <= m; i ++) {
if (p[i].empty()) {
sc[i] = 0;
continue;
}
if (p[i].size() == 1) {
sc[i] = p[i][0];
continue;
}
vector<PII> v = ff(p[i]);
sc[i] = -(nc+1);
for (int j = 0; j < (int) v.size(); j ++) {
int w = v[j].fi;
if (w < 0) w -= nc;
sx.pb(w);
w = v[j].se;
if (w < 0) w -= nc;
sy.pb(w);
}
nc += (int) v.size();
}
/*
for (int i = 0; i < (int) sc.size(); i ++)
printf("%d: %d\n", i, sc[i]);
for (int i = 0; i < (int) sx.size(); i ++)
printf("%d: %d %d\n", -(i+1), sx[i], sy[i]);
*/
answer(sc, sx, sy);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
204 KB |
Output is correct |
2 |
Correct |
38 ms |
6292 KB |
Output is correct |
3 |
Correct |
28 ms |
5164 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
13 ms |
3788 KB |
Output is correct |
6 |
Correct |
55 ms |
7700 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
204 KB |
Output is correct |
2 |
Correct |
38 ms |
6292 KB |
Output is correct |
3 |
Correct |
28 ms |
5164 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
13 ms |
3788 KB |
Output is correct |
6 |
Correct |
55 ms |
7700 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
58 ms |
7244 KB |
Output is correct |
9 |
Correct |
63 ms |
8556 KB |
Output is correct |
10 |
Correct |
113 ms |
11064 KB |
Output is correct |
11 |
Correct |
2 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
204 KB |
Output is correct |
2 |
Correct |
38 ms |
6292 KB |
Output is correct |
3 |
Correct |
28 ms |
5164 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
13 ms |
3788 KB |
Output is correct |
6 |
Correct |
55 ms |
7700 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
58 ms |
7244 KB |
Output is correct |
9 |
Correct |
63 ms |
8556 KB |
Output is correct |
10 |
Correct |
113 ms |
11064 KB |
Output is correct |
11 |
Correct |
2 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
167 ms |
10928 KB |
Output is correct |
15 |
Correct |
69 ms |
5776 KB |
Output is correct |
16 |
Correct |
94 ms |
8636 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
105 ms |
10672 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
244 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
204 KB |
Output is partially correct |
2 |
Correct |
55 ms |
5420 KB |
Output is correct |
3 |
Partially correct |
110 ms |
7936 KB |
Output is partially correct |
4 |
Partially correct |
135 ms |
8712 KB |
Output is partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
204 KB |
Output is partially correct |
2 |
Correct |
55 ms |
5420 KB |
Output is correct |
3 |
Partially correct |
110 ms |
7936 KB |
Output is partially correct |
4 |
Partially correct |
135 ms |
8712 KB |
Output is partially correct |
5 |
Partially correct |
119 ms |
12052 KB |
Output is partially correct |
6 |
Partially correct |
129 ms |
12504 KB |
Output is partially correct |
7 |
Partially correct |
168 ms |
12308 KB |
Output is partially correct |
8 |
Partially correct |
126 ms |
12840 KB |
Output is partially correct |
9 |
Partially correct |
107 ms |
10616 KB |
Output is partially correct |
10 |
Partially correct |
159 ms |
13468 KB |
Output is partially correct |
11 |
Partially correct |
147 ms |
13208 KB |
Output is partially correct |
12 |
Partially correct |
90 ms |
8676 KB |
Output is partially correct |
13 |
Partially correct |
83 ms |
8348 KB |
Output is partially correct |
14 |
Partially correct |
108 ms |
8188 KB |
Output is partially correct |
15 |
Partially correct |
77 ms |
7956 KB |
Output is partially correct |
16 |
Partially correct |
3 ms |
460 KB |
Output is partially correct |
17 |
Partially correct |
78 ms |
7192 KB |
Output is partially correct |
18 |
Partially correct |
79 ms |
7160 KB |
Output is partially correct |
19 |
Partially correct |
73 ms |
7576 KB |
Output is partially correct |
20 |
Partially correct |
100 ms |
9688 KB |
Output is partially correct |
21 |
Partially correct |
113 ms |
11536 KB |
Output is partially correct |
22 |
Partially correct |
94 ms |
9096 KB |
Output is partially correct |