Skip to content

Commit 2bdc0a0

Browse files
committed
remove some parens
1 parent 862d4f8 commit 2bdc0a0

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

library/graphs/functional_graph_processor.hpp

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,27 @@ struct func_graph {
1616
vector<basic_string<int>> cycle, childs;
1717
func_graph(const vi& a): root_of(sz(a)), childs(sz(a)) {
1818
vi state(sz(a));
19-
rep(i, 0, sz(a)) {
20-
if (state[i] == 0) {
21-
int u = i;
22-
while (state[u] == 0) {
23-
state[u] = 1;
19+
rep(i, 0, sz(a)) if (state[i] == 0) {
20+
int u = i;
21+
while (state[u] == 0) {
22+
state[u] = 1;
23+
u = a[u];
24+
}
25+
if (state[u] == 1) {
26+
cycle.emplace_back();
27+
while (state[u] == 1) {
28+
root_of[u] = {sz(cycle) - 1, sz(cycle.back())};
29+
cycle.back() += u;
30+
state[u] = 2;
2431
u = a[u];
2532
}
26-
if (state[u] == 1) {
27-
cycle.emplace_back();
28-
while (state[u] == 1) {
29-
root_of[u] = {sz(cycle) - 1, sz(cycle.back())};
30-
cycle.back() += u;
31-
state[u] = 2;
32-
u = a[u];
33-
}
34-
}
35-
int v = i;
36-
while (state[v] == 1) {
37-
root_of[v] = root_of[u];
38-
childs[a[v]] += v;
39-
state[v] = 2;
40-
v = a[v];
41-
}
33+
}
34+
int v = i;
35+
while (state[v] == 1) {
36+
root_of[v] = root_of[u];
37+
childs[a[v]] += v;
38+
state[v] = 2;
39+
v = a[v];
4240
}
4341
}
4442
}

0 commit comments

Comments
 (0)