// In the name of Allah
#include <bits/stdc++.h>
#include "doll.h"
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<ld> cld;
#define all(x) (x).begin(),(x).end()
#define len(x) ((ll) (x).size())
#define F first
#define S second
#define pb push_back
#define sep ' '
#define endl '\n'
#define Mp make_pair
#define kill(x) cout << x << '\n', exit(0)
#define set_dec(x) cout << fixed << setprecision(x);
#define file_io(x,y) freopen(x, "r", stdin); freopen(y, "w", stdout);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxn = 1e6 + 4;
int n, m, sz;
vector<int> ls[maxn];
vector<int> adj[maxn], Ax, A1, A2;
void solve(int v, vector<int> ls) {
if (len(ls) == 0) {
adj[v].pb(v);
return ;
}
else if (len(ls) == 1) {
adj[v].pb(ls[0]);
return ;
}
int u = sz++; adj[v].pb(u);
if (len(ls) % 2 == 1) {
reverse(all(ls)); ls.pb(u); reverse(all(ls));
}
vector<int> ls0, ls1;
for (int i = 0; i < len(ls); i++) {
if (i % 2 == 0) ls0.pb(ls[i]);
else ls1.pb(ls[i]);
}
solve(u, ls0); solve(u, ls1);
}
void create_circuit(int Mx, vector<int> A) {
m = Mx; n = len(A);
ls[0].pb(A[0]);
for (int i = 1; i < n; i++) {
ls[A[i - 1]].pb(A[i]);
}
ls[A.back()].pb(0);
sz = m + 1;
for (int i = 0; i <= m; i++) {
solve(i, ls[i]);
}
Ax.resize(m + 1); A1.resize(sz - m - 1); A2.resize(sz - m - 1);
for (int i = 0; i <= m; i++) {
int u = adj[i][0];
if (u <= m) Ax[i] = u;
else Ax[i] = -(u - m);
}
for (int i = m + 1; i < sz; i++) {
int j = i - m - 1;
int u1 = adj[i][0], u2 = adj[i][1];
if (u1 <= m) A1[j] = u1;
else A1[j] = -(u1 - m);
if (u2 <= m) A2[j] = u2;
else A2[j] = -(u2 - m);
}
answer(Ax, A1, A2);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
47196 KB |
Output is correct |
2 |
Correct |
40 ms |
54648 KB |
Output is correct |
3 |
Correct |
34 ms |
53080 KB |
Output is correct |
4 |
Correct |
18 ms |
47192 KB |
Output is correct |
5 |
Correct |
28 ms |
51656 KB |
Output is correct |
6 |
Correct |
45 ms |
56300 KB |
Output is correct |
7 |
Correct |
19 ms |
47192 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
47196 KB |
Output is correct |
2 |
Correct |
40 ms |
54648 KB |
Output is correct |
3 |
Correct |
34 ms |
53080 KB |
Output is correct |
4 |
Correct |
18 ms |
47192 KB |
Output is correct |
5 |
Correct |
28 ms |
51656 KB |
Output is correct |
6 |
Correct |
45 ms |
56300 KB |
Output is correct |
7 |
Correct |
19 ms |
47192 KB |
Output is correct |
8 |
Correct |
70 ms |
57680 KB |
Output is correct |
9 |
Correct |
57 ms |
58704 KB |
Output is correct |
10 |
Correct |
83 ms |
63316 KB |
Output is correct |
11 |
Correct |
17 ms |
47196 KB |
Output is correct |
12 |
Correct |
18 ms |
47192 KB |
Output is correct |
13 |
Correct |
18 ms |
47188 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
47196 KB |
Output is correct |
2 |
Correct |
40 ms |
54648 KB |
Output is correct |
3 |
Correct |
34 ms |
53080 KB |
Output is correct |
4 |
Correct |
18 ms |
47192 KB |
Output is correct |
5 |
Correct |
28 ms |
51656 KB |
Output is correct |
6 |
Correct |
45 ms |
56300 KB |
Output is correct |
7 |
Correct |
19 ms |
47192 KB |
Output is correct |
8 |
Correct |
70 ms |
57680 KB |
Output is correct |
9 |
Correct |
57 ms |
58704 KB |
Output is correct |
10 |
Correct |
83 ms |
63316 KB |
Output is correct |
11 |
Correct |
17 ms |
47196 KB |
Output is correct |
12 |
Correct |
18 ms |
47192 KB |
Output is correct |
13 |
Correct |
18 ms |
47188 KB |
Output is correct |
14 |
Correct |
98 ms |
66848 KB |
Output is correct |
15 |
Correct |
58 ms |
57168 KB |
Output is correct |
16 |
Correct |
79 ms |
62440 KB |
Output is correct |
17 |
Correct |
22 ms |
47196 KB |
Output is correct |
18 |
Correct |
18 ms |
47404 KB |
Output is correct |
19 |
Correct |
18 ms |
47192 KB |
Output is correct |
20 |
Correct |
87 ms |
64616 KB |
Output is correct |
21 |
Correct |
19 ms |
47196 KB |
Output is correct |
22 |
Correct |
18 ms |
47196 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
22 ms |
47196 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
17 ms |
47404 KB |
Output is partially correct |
2 |
Correct |
65 ms |
58260 KB |
Output is correct |
3 |
Partially correct |
106 ms |
68800 KB |
Output is partially correct |
4 |
Partially correct |
115 ms |
68300 KB |
Output is partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
17 ms |
47404 KB |
Output is partially correct |
2 |
Correct |
65 ms |
58260 KB |
Output is correct |
3 |
Partially correct |
106 ms |
68800 KB |
Output is partially correct |
4 |
Partially correct |
115 ms |
68300 KB |
Output is partially correct |
5 |
Partially correct |
125 ms |
70676 KB |
Output is partially correct |
6 |
Partially correct |
136 ms |
72980 KB |
Output is partially correct |
7 |
Partially correct |
129 ms |
72184 KB |
Output is partially correct |
8 |
Partially correct |
143 ms |
74008 KB |
Output is partially correct |
9 |
Partially correct |
107 ms |
66440 KB |
Output is partially correct |
10 |
Partially correct |
143 ms |
74024 KB |
Output is partially correct |
11 |
Partially correct |
153 ms |
75296 KB |
Output is partially correct |
12 |
Partially correct |
104 ms |
65412 KB |
Output is partially correct |
13 |
Partially correct |
93 ms |
63900 KB |
Output is partially correct |
14 |
Partially correct |
88 ms |
63236 KB |
Output is partially correct |
15 |
Partially correct |
83 ms |
62384 KB |
Output is partially correct |
16 |
Partially correct |
21 ms |
47708 KB |
Output is partially correct |
17 |
Partially correct |
87 ms |
61484 KB |
Output is partially correct |
18 |
Partially correct |
91 ms |
61476 KB |
Output is partially correct |
19 |
Partially correct |
92 ms |
62632 KB |
Output is partially correct |
20 |
Partially correct |
123 ms |
67084 KB |
Output is partially correct |
21 |
Partially correct |
130 ms |
71384 KB |
Output is partially correct |
22 |
Partially correct |
107 ms |
65660 KB |
Output is partially correct |