Skip to content

Commit 8c98bff

Browse files
committed
initial re-org
1 parent 54dc0f3 commit 8c98bff

File tree

12 files changed

+12
-19
lines changed

12 files changed

+12
-19
lines changed
File renamed without changes.

library/graphs/strongly_connected_components/scc.hpp renamed to library/graphs/scc.hpp

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

library/graphs/functional_graph_processor.hpp renamed to library/graphs/uncommon/functional_graph_processor.hpp

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,20 @@ struct func_graph {
1515
vector<pii> root_of;
1616
vector<vi> cycle, childs;
1717
func_graph(const vi& a): root_of(sz(a)), childs(sz(a)) {
18-
vi state(sz(a));
19-
rep(i, 0, sz(a)) if (!state[i]) {
18+
vi vis(sz(a));
19+
rep(i, 0, sz(a)) if (!vis[i]) {
2020
int u = i;
21-
while (!state[u]) {
22-
state[u] = 1;
23-
u = a[u];
24-
}
25-
if (state[u] == 1) {
26-
cycle.emplace_back();
27-
while (state[u] == 1) {
21+
for (; !vis[u]; u = a[u]) vis[u] = 1;
22+
if (vis[u] == 1)
23+
for (cycle.emplace_back(); vis[u] == 1; u = a[u]) {
2824
root_of[u] = {sz(cycle) - 1, sz(cycle.back())};
2925
cycle.back().push_back(u);
30-
state[u] = 2;
31-
u = a[u];
26+
vis[u] = 2;
3227
}
33-
}
34-
int v = i;
35-
while (state[v] == 1) {
28+
for (int v = i; vis[v] == 1; v = a[v]) {
3629
root_of[v] = root_of[u];
3730
childs[a[v]].push_back(v);
38-
state[v] = 2;
39-
v = a[v];
31+
vis[v] = 2;
4032
}
4133
}
4234
}

tests/library_checker_aizu_tests/handmade_tests/count_paths.test.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ vector<vector<ll>> naive(const vector<vi>& adj) {
1616
for (int node = u; node != v;
1717
node = lc.next_on_path(node, v))
1818
cnts_naive[path_length_edges][node]++;
19+
assert(path_length_edges < ssize(cnts_naive));
20+
assert(v < ssize(cnts_naive[path_length_edges]));
1921
cnts_naive[path_length_edges][v]++;
2022
}
2123
}
2224
return cnts_naive;
2325
}
2426
int main() {
2527
cin.tie(0)->sync_with_stdio(0);
26-
for (int n = 1; n <= 100; n++) {
28+
for (int n = 1; n <= 1; n++) {
2729
vector<vi> adj(n);
2830
for (int i = 1; i < n; i++) {
2931
int par = rnd<int>(0, i - 1);

0 commit comments

Comments
 (0)