Skip to content

Commit 7c44056

Browse files
committed
fix index out of bounds
1 parent 318f367 commit 7c44056

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/trees/uncommon/count_paths_per_length.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//! which are each O(n)
1010
vector<ll> count_paths_per_length(const vector<vi>& adj) {
1111
vector<ll> num_paths(sz(adj));
12-
num_paths[1] = sz(adj) - 1;
12+
if (sz(adj) >= 2) num_paths[1] = sz(adj) - 1;
1313
edge_cd(adj,
1414
[&](const vector<vi>& cd_adj, int cent, int split) {
1515
vector<vector<double>> cnt(2, vector<double>(1));

0 commit comments

Comments
 (0)