From a8eafeca112705e23f5d36f43148dea01538a1f7 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Mon, 9 Dec 2024 11:58:29 -0600 Subject: [PATCH 01/57] rerun tests with lower time limit --- .../workflows/programming_team_code_ci.yml | 2 +- .verify-helper/timestamps.remote.json | 140 ------------------ 2 files changed, 1 insertion(+), 141 deletions(-) delete mode 100644 .verify-helper/timestamps.remote.json diff --git a/.github/workflows/programming_team_code_ci.yml b/.github/workflows/programming_team_code_ci.yml index 4b1e67fe..cf3c95d2 100644 --- a/.github/workflows/programming_team_code_ci.yml +++ b/.github/workflows/programming_team_code_ci.yml @@ -27,7 +27,7 @@ jobs: - name: Run tests env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: oj-verify all --tle 35 --timeout 21600 + run: oj-verify all --tle 6 --timeout 21600 check_format_lint: runs-on: ubuntu-latest diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json deleted file mode 100644 index 825f956b..00000000 --- a/.verify-helper/timestamps.remote.json +++ /dev/null @@ -1,140 +0,0 @@ -{ -"tests/library_checker_aizu_tests/convolution/gcd_convolution.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/convolution/lcm_convolution.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/convolution/min_plus_convolution.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/data_structures/binary_search_example.test.cpp": "2024-11-18 10:51:39 -0600", -"tests/library_checker_aizu_tests/data_structures/binary_trie.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/data_structures/bit.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/bit_inc.test.cpp": "2024-11-18 09:44:22 -0600", -"tests/library_checker_aizu_tests/data_structures/bit_ordered_set.test.cpp": "2024-11-18 09:44:22 -0600", -"tests/library_checker_aizu_tests/data_structures/bit_rupq.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/bit_rurq.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/bit_walk.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/deque.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/deque_op.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/deque_sliding_window.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/disjoint_rmq_inc.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/disjoint_rmq_inc_lines.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/disjoint_rmq_lines.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/disjoint_rmq_sum.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/distinct_query.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/dsu_bipartite.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/data_structures/dsu_restorable.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/data_structures/dsu_segtree_undo_trick.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/implicit_seg_tree.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/data_structures/kruskal_tree_aizu.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/data_structures/kth_smallest_pst.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/kth_smallest_wavelet_matrix.test.cpp": "2024-11-19 08:31:51 -0600", -"tests/library_checker_aizu_tests/data_structures/lazy_segment_tree.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/lazy_segment_tree_constructor.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/lazy_segment_tree_inc.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/lazy_segment_tree_inc_constructor.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/line_tree_aizu.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/line_tree_lib_checker.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/data_structures/merge_sort_tree.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/data_structures/mode_query.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/permutation_tree.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/persistent_queue_tree.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/persistent_seg_tree.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/pq_ds_undo_sliding_window.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/pq_ds_undo_with_dsu.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/range_parallel_dsu.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/data_structures/rmq_all_methods.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/rmq_inc.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/simple_tree.test.cpp": "2024-12-06 01:57:17 -0600", -"tests/library_checker_aizu_tests/data_structures/simple_tree_inc.test.cpp": "2024-12-06 01:57:17 -0600", -"tests/library_checker_aizu_tests/data_structures/simple_tree_inc_line.test.cpp": "2024-12-06 01:57:17 -0600", -"tests/library_checker_aizu_tests/data_structures/simple_tree_line.test.cpp": "2024-12-06 01:57:17 -0600", -"tests/library_checker_aizu_tests/flow/dinic_aizu.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/flow/dinic_lib_checker.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/flow/hungarian.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/flow/min_cost_max_flow.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/graphs/biconnected_components.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/graphs/connected_components_of_complement_graph.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/graphs/dijkstra_aizu.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/graphs/dijkstra_lib_checker.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/graphs/directed_cycle.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/graphs/enumerate_triangles.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/graphs/hopcroft_karp_aizu.test.cpp": "2024-11-19 11:51:33 -0600", -"tests/library_checker_aizu_tests/graphs/hopcroft_karp_lib_checker.test.cpp": "2024-11-19 11:51:33 -0600", -"tests/library_checker_aizu_tests/graphs/mst.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/handmade_tests/count_paths_forest.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/handmade_tests/dsu_size.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/handmade_tests/dynamic_bitset.test.cpp": "2024-11-22 10:47:44 -0600", -"tests/library_checker_aizu_tests/handmade_tests/edge_cd_small_trees.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/handmade_tests/fib_matrix_expo.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/handmade_tests/lca_ladder_forest.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/handmade_tests/manacher.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/handmade_tests/merge_st_and_wavelet.test.cpp": "2024-11-19 08:31:51 -0600", -"tests/library_checker_aizu_tests/handmade_tests/mobius.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/handmade_tests/mod_int.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/handmade_tests/n_choose_k.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/handmade_tests/permutation_tree_small.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/handmade_tests/rmq_small_n.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/handmade_tests/sa_find_subarray.test.cpp": "2024-12-08 12:47:08 -0600", -"tests/library_checker_aizu_tests/handmade_tests/seg_tree_find.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/handmade_tests/seg_tree_find_small.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/handmade_tests/string_with_vector.test.cpp": "2024-12-08 12:47:08 -0600", -"tests/library_checker_aizu_tests/loops/chooses.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/loops/quotients.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/loops/submasks.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/loops/supermasks.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/math/binary_exponentiation_mod.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/math/binary_matrix_mult.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/math/count_paths.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/math/derangement.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/math/matrix_determinant.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/math/matrix_mult.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/math/mod_int_derangement.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/math/mod_int_gcd_convolution.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/math/mod_int_n_choose_k.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/math/mod_int_tetration.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/math/n_choose_k.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/math/num_subsequences.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/math/partitions.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/math/prime_sieve.test.cpp": "2024-11-22 11:54:52 -0600", -"tests/library_checker_aizu_tests/math/solve_linear_mod.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/math/tetration.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/math/totient.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/math/xor_basis.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/math/xor_basis_intersection.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_binary_tree.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_k_ary_tree.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/monotonic_stack_related/count_rectangles.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/monotonic_stack_related/max_rect_histogram.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/strings/kmp.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/strings/lcp_array.test.cpp": "2024-11-22 12:15:07 -0600", -"tests/library_checker_aizu_tests/strings/lcp_query_palindrome.test.cpp": "2024-12-08 12:47:08 -0600", -"tests/library_checker_aizu_tests/strings/lcp_query_zfunc.test.cpp": "2024-12-08 12:47:08 -0600", -"tests/library_checker_aizu_tests/strings/lcs_dp.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/strings/lcs_queries.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/strings/lcs_queries_merge_sort_tree.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/strings/longest_common_substring.test.cpp": "2024-12-08 12:47:08 -0600", -"tests/library_checker_aizu_tests/strings/manacher.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/strings/multi_matching_bs.test.cpp": "2024-12-08 12:47:08 -0600", -"tests/library_checker_aizu_tests/strings/prefix_function.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/strings/sa_cmp.test.cpp": "2024-12-08 12:47:08 -0600", -"tests/library_checker_aizu_tests/strings/sa_sort_pairs.test.cpp": "2024-12-08 12:47:08 -0600", -"tests/library_checker_aizu_tests/strings/single_matching_bs.test.cpp": "2024-12-08 12:47:08 -0600", -"tests/library_checker_aizu_tests/strings/suffix_array.test.cpp": "2024-12-08 12:47:08 -0600", -"tests/library_checker_aizu_tests/strings/suffix_array_short.test.cpp": "2024-11-22 12:15:07 -0600", -"tests/library_checker_aizu_tests/strings/trie.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/strings/wildcard_pattern_matching.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/trees/cd_jump_on_tree.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/trees/cd_lca.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/trees/count_paths_per_length.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/trees/edge_cd_contour_range_query.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/trees/edge_cd_contour_range_update.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/trees/edge_cd_count_paths_per_length.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/trees/kth_node_on_path.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/trees/ladder_decomposition.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/trees/lca_all_methods_aizu.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/trees/lca_all_methods_lib_checker.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/trees/subtree_isomorphism.test.cpp": "2024-11-17 14:04:03 -0600" -} \ No newline at end of file From da3e8da062f7f4c4fcad9431311e5404c089a1ce Mon Sep 17 00:00:00 2001 From: GitHub Date: Mon, 9 Dec 2024 19:55:57 +0000 Subject: [PATCH 02/57] [auto-verifier] verify commit a8eafeca112705e23f5d36f43148dea01538a1f7 --- .verify-helper/timestamps.remote.json | 111 ++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 .verify-helper/timestamps.remote.json diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json new file mode 100644 index 00000000..df442043 --- /dev/null +++ b/.verify-helper/timestamps.remote.json @@ -0,0 +1,111 @@ +{ +"tests/library_checker_aizu_tests/convolution/gcd_convolution.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/convolution/lcm_convolution.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/convolution/min_plus_convolution.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/data_structures/binary_search_example.test.cpp": "2024-11-18 10:51:39 -0600", +"tests/library_checker_aizu_tests/data_structures/binary_trie.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/data_structures/bit.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/bit_inc.test.cpp": "2024-11-18 09:44:22 -0600", +"tests/library_checker_aizu_tests/data_structures/bit_rupq.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/bit_rurq.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/bit_walk.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/deque.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/deque_op.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/deque_sliding_window.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/disjoint_rmq_inc.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/disjoint_rmq_inc_lines.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/disjoint_rmq_lines.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/disjoint_rmq_sum.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/distinct_query.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/dsu_bipartite.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/data_structures/dsu_restorable.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/data_structures/dsu_segtree_undo_trick.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/kruskal_tree_aizu.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/data_structures/kth_smallest_pst.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/kth_smallest_wavelet_matrix.test.cpp": "2024-11-19 08:31:51 -0600", +"tests/library_checker_aizu_tests/data_structures/lazy_segment_tree.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/lazy_segment_tree_constructor.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/lazy_segment_tree_inc.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/lazy_segment_tree_inc_constructor.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/line_tree_aizu.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/line_tree_lib_checker.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/data_structures/merge_sort_tree.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/data_structures/mode_query.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/permutation_tree.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/persistent_queue_tree.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/persistent_seg_tree.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/pq_ds_undo_sliding_window.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/pq_ds_undo_with_dsu.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/rmq_inc.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/simple_tree.test.cpp": "2024-12-06 01:57:17 -0600", +"tests/library_checker_aizu_tests/data_structures/simple_tree_inc.test.cpp": "2024-12-06 01:57:17 -0600", +"tests/library_checker_aizu_tests/data_structures/simple_tree_inc_line.test.cpp": "2024-12-06 01:57:17 -0600", +"tests/library_checker_aizu_tests/data_structures/simple_tree_line.test.cpp": "2024-12-06 01:57:17 -0600", +"tests/library_checker_aizu_tests/flow/dinic_aizu.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/flow/hungarian.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/flow/min_cost_max_flow.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/graphs/biconnected_components.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/graphs/connected_components_of_complement_graph.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/graphs/dijkstra_aizu.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/graphs/dijkstra_lib_checker.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/graphs/directed_cycle.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/graphs/enumerate_triangles.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/graphs/hopcroft_karp_aizu.test.cpp": "2024-11-19 11:51:33 -0600", +"tests/library_checker_aizu_tests/graphs/hopcroft_karp_lib_checker.test.cpp": "2024-11-19 11:51:33 -0600", +"tests/library_checker_aizu_tests/graphs/mst.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/handmade_tests/count_paths_forest.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/handmade_tests/dsu_size.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/handmade_tests/dynamic_bitset.test.cpp": "2024-11-22 10:47:44 -0600", +"tests/library_checker_aizu_tests/handmade_tests/fib_matrix_expo.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/handmade_tests/lca_ladder_forest.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/handmade_tests/manacher.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/handmade_tests/merge_st_and_wavelet.test.cpp": "2024-11-19 08:31:51 -0600", +"tests/library_checker_aizu_tests/handmade_tests/mod_int.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/handmade_tests/n_choose_k.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/handmade_tests/permutation_tree_small.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/handmade_tests/rmq_small_n.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/handmade_tests/sa_find_subarray.test.cpp": "2024-12-08 12:47:08 -0600", +"tests/library_checker_aizu_tests/handmade_tests/seg_tree_find.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/handmade_tests/seg_tree_find_small.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/handmade_tests/string_with_vector.test.cpp": "2024-12-08 12:47:08 -0600", +"tests/library_checker_aizu_tests/loops/chooses.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/loops/quotients.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/loops/submasks.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/loops/supermasks.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/math/binary_exponentiation_mod.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/math/binary_matrix_mult.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/math/derangement.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/math/matrix_determinant.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/math/mod_int_derangement.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/math/mod_int_gcd_convolution.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/math/mod_int_n_choose_k.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/math/mod_int_tetration.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/math/n_choose_k.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/math/num_subsequences.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/math/partitions.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/math/prime_sieve.test.cpp": "2024-11-22 11:54:52 -0600", +"tests/library_checker_aizu_tests/math/solve_linear_mod.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/math/tetration.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/math/totient.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_binary_tree.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/max_rect_histogram.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/strings/kmp.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/strings/lcp_query_zfunc.test.cpp": "2024-12-08 12:47:08 -0600", +"tests/library_checker_aizu_tests/strings/lcs_dp.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/strings/lcs_queries.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/strings/manacher.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/strings/multi_matching_bs.test.cpp": "2024-12-08 12:47:08 -0600", +"tests/library_checker_aizu_tests/strings/prefix_function.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/strings/sa_cmp.test.cpp": "2024-12-08 12:47:08 -0600", +"tests/library_checker_aizu_tests/strings/sa_sort_pairs.test.cpp": "2024-12-08 12:47:08 -0600", +"tests/library_checker_aizu_tests/strings/single_matching_bs.test.cpp": "2024-12-08 12:47:08 -0600", +"tests/library_checker_aizu_tests/strings/trie.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/strings/wildcard_pattern_matching.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/trees/edge_cd_contour_range_query.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/trees/edge_cd_contour_range_update.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/trees/lca_all_methods_aizu.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/trees/lca_all_methods_lib_checker.test.cpp": "2024-12-05 10:41:42 -0600" +} \ No newline at end of file From cbf3416c5381791c53650c97919f2acbc433c86a Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Tue, 10 Dec 2024 11:44:08 -0600 Subject: [PATCH 03/57] split up rmq test --- .../data_structures/rmq_all_methods.test.cpp | 37 ------------------- .../rmq_disjoint_sparse_table.test.cpp | 16 ++++++++ .../data_structures/rmq_linear.test.cpp | 19 ++++++++++ .../data_structures/rmq_sparse_table.test.cpp | 19 ++++++++++ 4 files changed, 54 insertions(+), 37 deletions(-) delete mode 100644 tests/library_checker_aizu_tests/data_structures/rmq_all_methods.test.cpp create mode 100644 tests/library_checker_aizu_tests/data_structures/rmq_disjoint_sparse_table.test.cpp create mode 100644 tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp create mode 100644 tests/library_checker_aizu_tests/data_structures/rmq_sparse_table.test.cpp diff --git a/tests/library_checker_aizu_tests/data_structures/rmq_all_methods.test.cpp b/tests/library_checker_aizu_tests/data_structures/rmq_all_methods.test.cpp deleted file mode 100644 index fa84e77d..00000000 --- a/tests/library_checker_aizu_tests/data_structures/rmq_all_methods.test.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#define PROBLEM "https://judge.yosupo.jp/problem/staticrmq" -#include "../template.hpp" -#include "../mono_st_asserts.hpp" -#include "../../../library/data_structures/rmq.hpp" -#include "../../../library/data_structures/uncommon/disjoint_rmq.hpp" -#include "../../../library/data_structures/uncommon/linear_rmq.hpp" -int mn(int x, int y) { return min(x, y); } -bool my_cmp(int x, int y) { return x < y; } -int main() { - cin.tie(0)->sync_with_stdio(0); - { - RMQ rmq_without_template(vector(), mn); - disjoint_rmq disjoint_rmq_without_template( - vector(), mn); - linear_rmq lin_rmq_without_template(vector(), - my_cmp); - } - int n, q; - cin >> n >> q; - vector a(n); - for (int i = 0; i < n; i++) cin >> a[i]; - mono_st_asserts(a); - RMQ rmq(a, [](auto x, auto y) { return min(x, y); }); - disjoint_rmq dis_rmq(a, - [](auto x, auto y) { return min(x, y); }); - linear_rmq lin_rmq(a, less()); - while (q--) { - int l, r; - cin >> l >> r; - int idx_min = lin_rmq.query_idx(l, r - 1); - assert(l <= idx_min && idx_min < r); - assert(lin_rmq.query(l, r - 1) == a[idx_min]); - assert(a[idx_min] == rmq.query(l, r)); - assert(a[idx_min] == dis_rmq.query(l, r)); - cout << a[idx_min] << '\n'; - } -} diff --git a/tests/library_checker_aizu_tests/data_structures/rmq_disjoint_sparse_table.test.cpp b/tests/library_checker_aizu_tests/data_structures/rmq_disjoint_sparse_table.test.cpp new file mode 100644 index 00000000..10924cc2 --- /dev/null +++ b/tests/library_checker_aizu_tests/data_structures/rmq_disjoint_sparse_table.test.cpp @@ -0,0 +1,16 @@ +#define PROBLEM "https://judge.yosupo.jp/problem/staticrmq" +#include "../template.hpp" +#include "../../../library/data_structures/uncommon/disjoint_rmq.hpp" +int main() { + cin.tie(0)->sync_with_stdio(0); + int n, q; + cin >> n >> q; + vector a(n); + for (int i = 0; i < n; i++) cin >> a[i]; + disjoint_rmq dis_rmq(a, ranges::min); + while (q--) { + int l, r; + cin >> l >> r; + cout << dis_rmq.query(l, r) << '\n'; + } +} diff --git a/tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp b/tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp new file mode 100644 index 00000000..a23c5e1e --- /dev/null +++ b/tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp @@ -0,0 +1,19 @@ +#define PROBLEM "https://judge.yosupo.jp/problem/staticrmq" +#include "../template.hpp" +#include "../../../library/data_structures/uncommon/linear_rmq.hpp" +int main() { + cin.tie(0)->sync_with_stdio(0); + int n, q; + cin >> n >> q; + vector a(n); + for (int i = 0; i < n; i++) cin >> a[i]; + linear_rmq lin_rmq(a, less()); + while (q--) { + int l, r; + cin >> l >> r; + int idx_min = lin_rmq.query_idx(l, r - 1); + assert(l <= idx_min && idx_min < r); + assert(lin_rmq.query(l, r - 1) == a[idx_min]); + cout << a[idx_min] << '\n'; + } +} diff --git a/tests/library_checker_aizu_tests/data_structures/rmq_sparse_table.test.cpp b/tests/library_checker_aizu_tests/data_structures/rmq_sparse_table.test.cpp new file mode 100644 index 00000000..60f27454 --- /dev/null +++ b/tests/library_checker_aizu_tests/data_structures/rmq_sparse_table.test.cpp @@ -0,0 +1,19 @@ +#define PROBLEM "https://judge.yosupo.jp/problem/staticrmq" +#include "../template.hpp" +#include "../mono_st_asserts.hpp" +#include "../../../library/data_structures/rmq.hpp" +int mn(int x, int y) { return min(x, y); } +int main() { + cin.tie(0)->sync_with_stdio(0); + int n, q; + cin >> n >> q; + vector a(n); + for (int i = 0; i < n; i++) cin >> a[i]; + mono_st_asserts(a); + RMQ rmq(a, ranges::min); + while (q--) { + int l, r; + cin >> l >> r; + cout << rmq.query(l, r) << '\n'; + } +} From 53332ccb36befbf20c3d5a6731952d27773090d0 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Tue, 10 Dec 2024 11:52:04 -0600 Subject: [PATCH 04/57] fix this test --- .../data_structures/bit_ordered_set.test.cpp | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/tests/library_checker_aizu_tests/data_structures/bit_ordered_set.test.cpp b/tests/library_checker_aizu_tests/data_structures/bit_ordered_set.test.cpp index 7c61c69b..24cbfb29 100644 --- a/tests/library_checker_aizu_tests/data_structures/bit_ordered_set.test.cpp +++ b/tests/library_checker_aizu_tests/data_structures/bit_ordered_set.test.cpp @@ -19,19 +19,25 @@ int main() { ranges::sort(compress); compress.erase(unique(all(compress)), end(compress)); bit_inc bit(ssize(compress)); + auto get_compressed_idx = [&](int val) -> int { + int l = 0, r = ssize(compress); + while (l + 1 < r) { + int m = (l + r) / 2; + if (compress[m] <= val) l = m; + else r = m; + } + return l; + }; for (int i = 0; i < n; i++) { - int val = ranges::lower_bound(compress, init[i]) - - begin(compress); + int val = get_compressed_idx(init[i]); bit.update(val, 1); } for (auto [type, x] : query) { if (type == 0) { - x = - ranges::lower_bound(compress, x) - begin(compress); + x = get_compressed_idx(x); if (bit.query(x, x) == 0) bit.update(x, 1); } else if (type == 1) { - x = - ranges::lower_bound(compress, x) - begin(compress); + x = get_compressed_idx(x); if (bit.query(x, x) == 1) bit.update(x, -1); } else if (type == 2) { int res = bit.walk(x); @@ -39,18 +45,15 @@ int main() { cout << -1 << '\n'; else cout << compress[res] << '\n'; } else if (type == 3) { - x = - ranges::lower_bound(compress, x) - begin(compress); + x = get_compressed_idx(x); cout << bit.query(x) << '\n'; } else if (type == 4) { - x = - ranges::lower_bound(compress, x) - begin(compress); + x = get_compressed_idx(x); int res = bit.prev(x); if (res == -1) cout << -1 << '\n'; else cout << compress[res] << '\n'; } else { - x = - ranges::lower_bound(compress, x) - begin(compress); + x = get_compressed_idx(x); int res = bit.next(x); if (res == ssize(bit.s)) cout << -1 << '\n'; else cout << compress[res] << '\n'; From 094a2c8b3e161c8cca70a151c28b495569da190b Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Tue, 10 Dec 2024 12:01:08 -0600 Subject: [PATCH 05/57] fix --- .../data_structures/range_parallel_dsu.test.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/library_checker_aizu_tests/data_structures/range_parallel_dsu.test.cpp b/tests/library_checker_aizu_tests/data_structures/range_parallel_dsu.test.cpp index 3dd445ad..20806310 100644 --- a/tests/library_checker_aizu_tests/data_structures/range_parallel_dsu.test.cpp +++ b/tests/library_checker_aizu_tests/data_structures/range_parallel_dsu.test.cpp @@ -2,7 +2,6 @@ "https://judge.yosupo.jp/problem/range_parallel_unionfind" #include "../template.hpp" #include "../../../library/data_structures/dsu/range_parallel_dsu.hpp" -#include "../../../library/contest/random.hpp" #include "../../../library/data_structures/dsu/range_parallel_equivalence_classes.hpp" #include "../../../library/math/mod_int.hpp" int main() { @@ -29,8 +28,7 @@ int main() { dsu.join(a, b, k, f); queries.push_back({a, b, k}); cout << ans.x << '\n'; - if (qq <= 10 || abs(q - qq) <= 10 || - rnd(0, 50'000) == 0) { + if (qq < 3 || abs(q - qq) <= 3 || qq % 100'000 == 0) { auto uf = get_rp_dsu(queries, n); vector sums(n); mint offline_ans = 0; From b97c3f5a6d94b73c0b1209ef4b1e6a2b0a9512ec Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Tue, 10 Dec 2024 12:06:44 -0600 Subject: [PATCH 06/57] tiny speedup --- .../seg_tree_uncommon/implicit.hpp | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/library/data_structures/seg_tree_uncommon/implicit.hpp b/library/data_structures/seg_tree_uncommon/implicit.hpp index 76a6570b..5e7ef13b 100644 --- a/library/data_structures/seg_tree_uncommon/implicit.hpp +++ b/library/data_structures/seg_tree_uncommon/implicit.hpp @@ -2,23 +2,23 @@ //! @code //! implicit_seg_tree<10'000'000> ist(l, r); //! @endcode -template struct implicit_seg_tree { - using dt = array; //!< min, number of mins +template struct implicit_seg_tree { + using dt = array; //!< min, number of mins static dt op(const dt& l, const dt& r) { if (l[0] == r[0]) return {l[0], l[1] + r[1]}; return min(l, r); } - static constexpr dt unit{LLONG_MAX, 0LL}; + static constexpr dt unit{INT_MAX, 0}; struct node { dt num; - ll lazy = 0; + int lazy = 0; int lch = -1, rch = -1; } tree[N]; int ptr = 0, root_l, root_r; - implicit_seg_tree(int l, int r): root_l(l), root_r(r) { + implicit_seg_tree(int l, int r) : root_l(l), root_r(r) { tree[ptr++].num = {0, r - l}; } - void apply(ll add, int v) { + void apply(int add, int v) { tree[v].num[0] += add; tree[v].lazy += add; } @@ -35,11 +35,11 @@ template struct implicit_seg_tree { tree[v].lazy = 0; } } - void update(int l, int r, ll add) { // [l, r) + void update(int l, int r, int add) { // [l, r) update(l, r, add, root_l, root_r, 0); } - void update(int l, int r, ll add, int tl, int tr, - int v) { + void update(int l, int r, int add, int tl, int tr, + int v) { if (r <= tl || tr <= l) return; if (l <= tl && tr <= r) return apply(add, v); int tm = tl + (tr - tl) / 2; @@ -47,9 +47,9 @@ template struct implicit_seg_tree { update(l, r, add, tl, tm, tree[v].lch); update(l, r, add, tm, tr, tree[v].rch); tree[v].num = - op(tree[tree[v].lch].num, tree[tree[v].rch].num); + op(tree[tree[v].lch].num, tree[tree[v].rch].num); } - dt query(int l, int r) { // [l, r) + dt query(int l, int r) { // [l, r) return query(l, r, root_l, root_r, 0); } dt query(int l, int r, int tl, int tr, int v) { @@ -58,6 +58,6 @@ template struct implicit_seg_tree { int tm = tl + (tr - tl) / 2; push(tl, tm, tr, v); return op(query(l, r, tl, tm, tree[v].lch), - query(l, r, tm, tr, tree[v].rch)); + query(l, r, tm, tr, tree[v].rch)); } }; From 530291c51d70b9938cf6648a9bea79583230b3ad Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Tue, 10 Dec 2024 12:20:04 -0600 Subject: [PATCH 07/57] remove cuz it's too slow --- .../flow/dinic_lib_checker.test.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/library_checker_aizu_tests/flow/dinic_lib_checker.test.cpp b/tests/library_checker_aizu_tests/flow/dinic_lib_checker.test.cpp index 875d720d..a8aa244f 100644 --- a/tests/library_checker_aizu_tests/flow/dinic_lib_checker.test.cpp +++ b/tests/library_checker_aizu_tests/flow/dinic_lib_checker.test.cpp @@ -1,6 +1,15 @@ #define PROBLEM \ "https://judge.yosupo.jp/problem/bipartitematching" +#undef _GLIBCXX_DEBUG +#undef _GLIBCXX_ASSERTIONS +#undef _GLIBCXX_SANITIZE_VECTOR +#undef _GLIBCXX_DEBUG_PEDANTIC + #include "../template.hpp" +#undef ll +#define ll int +#undef LLONG_MAX +#define LLONG_MAX 1'000'000'000 #include "../../../library/flow/dinic.hpp" #include "../dinic_asserts.hpp" int main() { @@ -20,7 +29,7 @@ int main() { } ll total_flow = d.calc(source, sink); cout << total_flow << '\n'; - dinic_asserts(d, source, sink, total_flow); + // dinic_asserts(d, source, sink, total_flow); for (int i = 0; i < m; i++) { dinic::edge an_edge = d.edges[edge_ids[i]]; if (an_edge.flow() == 1) From 3b6a3ef82e009de1d880dde5ef7065bb44063084 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Tue, 10 Dec 2024 12:25:51 -0600 Subject: [PATCH 08/57] speed up test --- .../graphs/offline_incremental_scc.test.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp b/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp index fb38b033..3a99257b 100644 --- a/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp +++ b/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp @@ -1,10 +1,10 @@ #define PROBLEM \ "https://judge.yosupo.jp/problem/incremental_scc" +// to speed up test +#undef _GLIBCXX_DEBUG #include "../template.hpp" #include "../../../kactl/content/data-structures/UnionFind.h" -#include "../../../library/contest/random.hpp" #include "../../../library/graphs/strongly_connected_components/offline_incremental_scc.hpp" -#include "../../../library/graphs/strongly_connected_components/scc.hpp" #include "../../../library/math/mod_int.hpp" int main() { cin.tie(0)->sync_with_stdio(0); @@ -17,11 +17,10 @@ int main() { auto joins = offline_incremental_scc(eds, n); // assert joins[i] == -1 for self-edges for (int t = 0; t < m; t++) - if (eds[t][0] == eds[t][1]) assert(joins[t] == -1); + assert((eds[t][0] == eds[t][1]) == (joins[t] == -1)); vector order(m); iota(all(order), 0); - sort(all(order), - [&](int i, int j) { return joins[i] < joins[j]; }); + ranges::sort(all(order), {}, [&](int i) { return joins[i]; }); UF uf(n); mint sum = 0; for (int t = 0, it = 0; t < m; t++) { From f7a6ac2450ff658e04537bd613b816b000699542 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Tue, 10 Dec 2024 12:26:47 -0600 Subject: [PATCH 09/57] also use std::midpoint --- .../offline_incremental_scc.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp index 7c2748cc..98971c67 100644 --- a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp +++ b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp @@ -11,13 +11,13 @@ //! @time O((n + m) log m) //! @space O(n + m) vi offline_incremental_scc(vector> eds, - int n) { + int n) { int m = sz(eds); vi ids(n, -1), joins(m, m), idx(m); iota(all(idx), 0); auto divide_and_conquer = [&](auto&& self, auto el, - auto er, int tl, int tr) { - int mid = tl + (tr - tl) / 2; + auto er, int tl, int tr) { + int mid = midpoint(tl, tr); vi vs; vector adj; for (auto it = el; it != er; it++) { From 465ef0d05f0b61c30324296a0ace43b1b8ebefbf Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Tue, 10 Dec 2024 12:27:45 -0600 Subject: [PATCH 10/57] decrease --- .../handmade_tests/edge_cd_small_trees.test.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/library_checker_aizu_tests/handmade_tests/edge_cd_small_trees.test.cpp b/tests/library_checker_aizu_tests/handmade_tests/edge_cd_small_trees.test.cpp index 81f1cfb8..d677546c 100644 --- a/tests/library_checker_aizu_tests/handmade_tests/edge_cd_small_trees.test.cpp +++ b/tests/library_checker_aizu_tests/handmade_tests/edge_cd_small_trees.test.cpp @@ -9,21 +9,21 @@ int main() { { vector> adj; edge_cd(adj, - [&](const vector>&, int, int) -> void { - assert(false); - }); + [&](const vector>&, int, int) -> void { + assert(false); + }); } { vector> adj(1); edge_cd(adj, - [&](const vector>&, int, int) -> void { - assert(false); - }); + [&](const vector>&, int, int) -> void { + assert(false); + }); } - for (int n = 2; n <= 8; n++) { + for (int n = 2; n <= 7; n++) { int num_codes = mpow(n, n - 2).x; vector> pruf_codes(num_codes, - vector(n - 2)); + vector(n - 2)); for (int i = 0; i < num_codes; i++) { int val = i; for (int j = 0; j < n - 2; j++) { From 8c9b13a3dfdb7447eb874d1abc3c64d17d7c5da4 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Tue, 10 Dec 2024 12:28:47 -0600 Subject: [PATCH 11/57] decrease --- .../handmade_tests/functional_graph.test.cpp | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp b/tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp index b1b661b5..12de5244 100644 --- a/tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp +++ b/tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp @@ -9,7 +9,7 @@ struct functional_graph_processor { init(sz(next)); build(next); } - template + template functional_graph_processor(const Graph_t &g) { init(g.n); build(g); @@ -101,28 +101,28 @@ struct functional_graph_processor { } int n; vector> cycle; - vector cycle_id; // id of the cycle it belongs to, - // -1 if not part of one - vector cycle_pos; // position in its cycle, -1 if - // not part of one - vector cycle_prev; // previous vertex in its cycle, - // -1 if not part of one - vector component_size; // size of its weakly - // connected component - vector root_of; // first reachable node in a cycle - vector depth; // distance to its root + vector cycle_id; // id of the cycle it belongs to, + // -1 if not part of one + vector cycle_pos; // position in its cycle, -1 if + // not part of one + vector cycle_prev; // previous vertex in its cycle, + // -1 if not part of one + vector component_size; // size of its weakly + // connected component + vector root_of; // first reachable node in a cycle + vector depth; // distance to its root vector> - abr; // forest of arborescences of reversed edges not - // on the cycles - vector order; // dfs order of abr - vector pos; // pos in the dfs order - vector end; // [pos[u], end[u]) denotes the subtree - vector size; // size of the subtree in abr + abr; // forest of arborescences of reversed edges not + // on the cycles + vector order; // dfs order of abr + vector pos; // pos in the dfs order + vector end; // [pos[u], end[u]) denotes the subtree + vector size; // size of the subtree in abr }; int main() { cin.tie(0)->sync_with_stdio(0); - for (int num_tests = 1000; num_tests--;) { - int n = rnd(1, 10000); + for (int num_tests = 100; num_tests--;) { + int n = rnd(1, 1000); vector a(n); for (int i = 0; i < n; i++) a[i] = rnd(0, n - 1); auto [t, cycle] = func_graph(a); @@ -130,7 +130,7 @@ int main() { assert(cycle == fgp.cycle); for (int i = 0; i < n; i++) { int root = - cycle[t[i].root_of.first][t[i].root_of.second]; + cycle[t[i].root_of.first][t[i].root_of.second]; assert(root == fgp.root_of[i]); assert(t[i].childs == fgp.abr[i]); assert((root == i) == (fgp.cycle_id[i] != -1)); @@ -139,13 +139,13 @@ int main() { assert(t[i].root_of.second == fgp.cycle_pos[i]); int cyc_len = ssize(cycle[t[i].root_of.first]); assert( - cycle[t[i].root_of.first] - [(t[i].root_of.second + 1) % cyc_len] == - a[i]); + cycle[t[i].root_of.first] + [(t[i].root_of.second + 1) % cyc_len] == + a[i]); assert(fgp.cycle_prev[i] == - cycle[t[i].root_of.first] - [(t[i].root_of.second - 1 + cyc_len) % - cyc_len]); + cycle[t[i].root_of.first] + [(t[i].root_of.second - 1 + cyc_len) % + cyc_len]); } else { assert(fgp.cycle_prev[i] == -1); } From 22d826f9cdf8c04a63d3caa875fe60a93656fbb6 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Tue, 10 Dec 2024 12:31:07 -0600 Subject: [PATCH 12/57] decrease bound --- library/math/prime_sieve/mobius.hpp | 2 +- tests/library_checker_aizu_tests/handmade_tests/mobius.test.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/library/math/prime_sieve/mobius.hpp b/library/math/prime_sieve/mobius.hpp index 1e55ff3e..00b8e182 100644 --- a/library/math/prime_sieve/mobius.hpp +++ b/library/math/prime_sieve/mobius.hpp @@ -1,7 +1,7 @@ #pragma once //! @time O(mx log mx) //! @space O(mx) -vi mobius(1'000'005); +vi mobius(100'005); mobius[1] = 1; rep(i, 1, sz(mobius)) for (int j = i + i; j < sz(mobius); j += i) mobius[j] -= mobius[i]; diff --git a/tests/library_checker_aizu_tests/handmade_tests/mobius.test.cpp b/tests/library_checker_aizu_tests/handmade_tests/mobius.test.cpp index dffcef79..0132e131 100644 --- a/tests/library_checker_aizu_tests/handmade_tests/mobius.test.cpp +++ b/tests/library_checker_aizu_tests/handmade_tests/mobius.test.cpp @@ -5,7 +5,6 @@ int main() { cin.tie(0)->sync_with_stdio(0); #include "../../../library/math/prime_sieve/mobius.hpp" -#include "../../../library/math/prime_sieve/calc_sieve.hpp" #include "../../../library/math/prime_sieve/is_prime.hpp" assert(is_prime(2)); for (int i = 1; i < sz(mobius); i++) { From 60568843711b3b8a35923f04cad9a49c18d72ddd Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Tue, 10 Dec 2024 12:50:49 -0600 Subject: [PATCH 13/57] actually revert this --- .../graphs/offline_incremental_scc.test.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp b/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp index 3a99257b..a7e3a2b5 100644 --- a/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp +++ b/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp @@ -1,7 +1,5 @@ #define PROBLEM \ "https://judge.yosupo.jp/problem/incremental_scc" -// to speed up test -#undef _GLIBCXX_DEBUG #include "../template.hpp" #include "../../../kactl/content/data-structures/UnionFind.h" #include "../../../library/graphs/strongly_connected_components/offline_incremental_scc.hpp" From 7b69b73f91b5c15da4f9d63274bb2643bbd54886 Mon Sep 17 00:00:00 2001 From: GitHub Date: Tue, 10 Dec 2024 19:58:43 +0000 Subject: [PATCH 14/57] [auto-verifier] verify commit 60568843711b3b8a35923f04cad9a49c18d72ddd --- .verify-helper/timestamps.remote.json | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index df442043..e6f29880 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -6,6 +6,7 @@ "tests/library_checker_aizu_tests/data_structures/binary_trie.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/data_structures/bit.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/data_structures/bit_inc.test.cpp": "2024-11-18 09:44:22 -0600", +"tests/library_checker_aizu_tests/data_structures/bit_ordered_set.test.cpp": "2024-12-10 11:52:04 -0600", "tests/library_checker_aizu_tests/data_structures/bit_rupq.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/data_structures/bit_rurq.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/data_structures/bit_walk.test.cpp": "2024-12-05 10:41:42 -0600", @@ -36,33 +37,39 @@ "tests/library_checker_aizu_tests/data_structures/persistent_seg_tree.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/data_structures/pq_ds_undo_sliding_window.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/data_structures/pq_ds_undo_with_dsu.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/rmq_disjoint_sparse_table.test.cpp": "2024-12-10 11:44:08 -0600", "tests/library_checker_aizu_tests/data_structures/rmq_inc.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp": "2024-12-10 11:44:08 -0600", "tests/library_checker_aizu_tests/data_structures/simple_tree.test.cpp": "2024-12-06 01:57:17 -0600", "tests/library_checker_aizu_tests/data_structures/simple_tree_inc.test.cpp": "2024-12-06 01:57:17 -0600", "tests/library_checker_aizu_tests/data_structures/simple_tree_inc_line.test.cpp": "2024-12-06 01:57:17 -0600", "tests/library_checker_aizu_tests/data_structures/simple_tree_line.test.cpp": "2024-12-06 01:57:17 -0600", "tests/library_checker_aizu_tests/flow/dinic_aizu.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/flow/dinic_lib_checker.test.cpp": "2024-12-10 12:20:04 -0600", "tests/library_checker_aizu_tests/flow/hungarian.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/flow/min_cost_max_flow.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/graphs/biconnected_components.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/graphs/connected_components_of_complement_graph.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/graphs/dijkstra_aizu.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/graphs/dijkstra_lib_checker.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/graphs/directed_cycle.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/graphs/directed_cycle.test.cpp": "2024-12-10 12:26:47 -0600", "tests/library_checker_aizu_tests/graphs/enumerate_triangles.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/graphs/hopcroft_karp_aizu.test.cpp": "2024-11-19 11:51:33 -0600", "tests/library_checker_aizu_tests/graphs/hopcroft_karp_lib_checker.test.cpp": "2024-11-19 11:51:33 -0600", "tests/library_checker_aizu_tests/graphs/mst.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp": "2024-12-10 12:26:47 -0600", +"tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp": "2024-12-10 12:26:47 -0600", "tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/handmade_tests/count_paths_forest.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/handmade_tests/dsu_size.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/handmade_tests/dynamic_bitset.test.cpp": "2024-11-22 10:47:44 -0600", +"tests/library_checker_aizu_tests/handmade_tests/edge_cd_small_trees.test.cpp": "2024-12-10 12:27:45 -0600", "tests/library_checker_aizu_tests/handmade_tests/fib_matrix_expo.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp": "2024-12-10 12:28:47 -0600", "tests/library_checker_aizu_tests/handmade_tests/lca_ladder_forest.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/handmade_tests/manacher.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/handmade_tests/merge_st_and_wavelet.test.cpp": "2024-11-19 08:31:51 -0600", +"tests/library_checker_aizu_tests/handmade_tests/mobius.test.cpp": "2024-12-10 12:31:07 -0600", "tests/library_checker_aizu_tests/handmade_tests/mod_int.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/handmade_tests/n_choose_k.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/handmade_tests/permutation_tree_small.test.cpp": "2024-12-05 10:41:42 -0600", @@ -106,6 +113,7 @@ "tests/library_checker_aizu_tests/strings/wildcard_pattern_matching.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/trees/edge_cd_contour_range_query.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/trees/edge_cd_contour_range_update.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/trees/ladder_decomposition.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/trees/lca_all_methods_aizu.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/trees/lca_all_methods_lib_checker.test.cpp": "2024-12-05 10:41:42 -0600" } \ No newline at end of file From b13b49c9b6251d8ba63c661867781965ec71a073 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Tue, 10 Dec 2024 20:34:52 -0600 Subject: [PATCH 15/57] fix --- .../math/count_paths/count_paths_triangle.hpp | 8 ++-- .../range_parallel_dsu.test.cpp | 4 +- .../flow/dinic_lib_checker.test.cpp | 39 ------------------- 3 files changed, 7 insertions(+), 44 deletions(-) delete mode 100644 tests/library_checker_aizu_tests/flow/dinic_lib_checker.test.cpp diff --git a/library/math/count_paths/count_paths_triangle.hpp b/library/math/count_paths/count_paths_triangle.hpp index bc012b33..0a207d3c 100644 --- a/library/math/count_paths/count_paths_triangle.hpp +++ b/library/math/count_paths/count_paths_triangle.hpp @@ -6,7 +6,7 @@ vl divide_and_conquer(vl h, vl bottom) { { int start = - find_if(all(h), [](ll x) { return x; }) - begin(h); + ranges::find_if(h, [](ll x) { return x; }) - begin(h); h.erase(begin(h), begin(h) + start); bottom.erase(begin(bottom), begin(bottom) + start); } @@ -15,10 +15,10 @@ vl divide_and_conquer(vl h, vl bottom) { if (n == 1) return vl(h[0], bottom[0]); int mid = n / 2; auto rect_left = - divide_and_conquer(vl(begin(h), begin(h) + mid), - vl(begin(bottom), begin(bottom) + mid)); + divide_and_conquer(vl(begin(h), begin(h) + mid), + vl(begin(bottom), begin(bottom) + mid)); auto [rect_right, rect_top] = - get_right_and_top(rect_left, vl(mid + all(bottom))); + get_right_and_top(rect_left, vl(mid + all(bottom))); vl h_right(mid + all(h)); for (ll& hh : h_right) hh -= h[mid - 1]; auto upper_right = divide_and_conquer(h_right, rect_top); diff --git a/tests/library_checker_aizu_tests/data_structures/range_parallel_dsu.test.cpp b/tests/library_checker_aizu_tests/data_structures/range_parallel_dsu.test.cpp index 20806310..3d01d17f 100644 --- a/tests/library_checker_aizu_tests/data_structures/range_parallel_dsu.test.cpp +++ b/tests/library_checker_aizu_tests/data_structures/range_parallel_dsu.test.cpp @@ -1,5 +1,6 @@ #define PROBLEM \ "https://judge.yosupo.jp/problem/range_parallel_unionfind" +#undef _GLIBCXX_DEBUG #include "../template.hpp" #include "../../../library/data_structures/dsu/range_parallel_dsu.hpp" #include "../../../library/data_structures/dsu/range_parallel_equivalence_classes.hpp" @@ -22,13 +23,14 @@ int main() { x[u] = x[u] + x[v]; }; vector> queries; + queries.reserve(q); for (int qq = 0; qq < q; qq++) { int k, a, b; cin >> k >> a >> b; dsu.join(a, b, k, f); queries.push_back({a, b, k}); cout << ans.x << '\n'; - if (qq < 3 || abs(q - qq) <= 3 || qq % 100'000 == 0) { + if (qq == 0 || qq == 1 || qq == 10 || qq == 1000 || qq == 100'000 || qq == q - 1) { auto uf = get_rp_dsu(queries, n); vector sums(n); mint offline_ans = 0; diff --git a/tests/library_checker_aizu_tests/flow/dinic_lib_checker.test.cpp b/tests/library_checker_aizu_tests/flow/dinic_lib_checker.test.cpp deleted file mode 100644 index a8aa244f..00000000 --- a/tests/library_checker_aizu_tests/flow/dinic_lib_checker.test.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#define PROBLEM \ - "https://judge.yosupo.jp/problem/bipartitematching" -#undef _GLIBCXX_DEBUG -#undef _GLIBCXX_ASSERTIONS -#undef _GLIBCXX_SANITIZE_VECTOR -#undef _GLIBCXX_DEBUG_PEDANTIC - -#include "../template.hpp" -#undef ll -#define ll int -#undef LLONG_MAX -#define LLONG_MAX 1'000'000'000 -#include "../../../library/flow/dinic.hpp" -#include "../dinic_asserts.hpp" -int main() { - cin.tie(0)->sync_with_stdio(0); - int l, r, m; - cin >> l >> r >> m; - const int source = l + r; - const int sink = l + r + 1; - dinic d(l + r + 2); - for (int i = 0; i < l; i++) d.add_edge(source, i, 1); - for (int i = 0; i < r; i++) d.add_edge(i + l, sink, 1); - vector edge_ids(m); - for (int i = 0; i < m; i++) { - int u, v; - cin >> u >> v; - edge_ids[i] = d.add_edge(u, v + l, 1); - } - ll total_flow = d.calc(source, sink); - cout << total_flow << '\n'; - // dinic_asserts(d, source, sink, total_flow); - for (int i = 0; i < m; i++) { - dinic::edge an_edge = d.edges[edge_ids[i]]; - if (an_edge.flow() == 1) - cout << an_edge.v << ' ' << an_edge.to - l << '\n'; - } - return 0; -} From ddee6c9cae8c476faa316c54cfe052c0848a6bcb Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Tue, 10 Dec 2024 21:07:31 -0600 Subject: [PATCH 16/57] fix --- .../data_structures/rmq_linear.test.cpp | 22 ++++++++--- .../mono_st_asserts.hpp | 37 +++---------------- 2 files changed, 23 insertions(+), 36 deletions(-) diff --git a/tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp b/tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp index a23c5e1e..22358b00 100644 --- a/tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp +++ b/tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp @@ -7,13 +7,25 @@ int main() { cin >> n >> q; vector a(n); for (int i = 0; i < n; i++) cin >> a[i]; - linear_rmq lin_rmq(a, less()); + linear_rmq rmq_less(a, less()); + linear_rmq rmq_less_equal(a, less_equal()); + vector neg_a(n); + for (int i = 0; i < n; i++) neg_a[i] = -a[i]; + linear_rmq rmq_greater(neg_a, greater()); + linear_rmq rmq_greater_equal(neg_a, greater_equal()); while (q--) { int l, r; cin >> l >> r; - int idx_min = lin_rmq.query_idx(l, r - 1); - assert(l <= idx_min && idx_min < r); - assert(lin_rmq.query(l, r - 1) == a[idx_min]); - cout << a[idx_min] << '\n'; + int idx_right_min = rmq_less.query_idx(l, r - 1); + assert(idx_right_min + 1 == r || rmq_less.query(idx_right_min + 1, r - 1) > a[idx_right_min]); + assert(l <= idx_right_min && idx_right_min < r); + assert(rmq_less.query(l, r - 1) == a[idx_right_min]); + assert(idx_right_min == rmq_greater.query_idx(l, r - 1)); + int idx_left_min = rmq_less_equal.query_idx(l, r - 1); + assert(l <= idx_left_min && idx_left_min < r); + assert(idx_left_min == rmq_greater_equal.query_idx(l, r - 1)); + assert(a[idx_right_min] == a[idx_left_min]); + assert(idx_left_min <= idx_right_min); + cout << a[idx_right_min] << '\n'; } } diff --git a/tests/library_checker_aizu_tests/mono_st_asserts.hpp b/tests/library_checker_aizu_tests/mono_st_asserts.hpp index 706f340b..33df6820 100644 --- a/tests/library_checker_aizu_tests/mono_st_asserts.hpp +++ b/tests/library_checker_aizu_tests/mono_st_asserts.hpp @@ -6,7 +6,7 @@ #include "../../library/data_structures/uncommon/linear_rmq.hpp" tuple>, vector> min_cartesian_tree(const vector& a, - const vector& l, const vector& r) { + const vector& l, const vector& r) { int n = sz(a); assert(sz(l) == n && sz(r) == n); auto is_node = [&](int i) -> bool { @@ -24,7 +24,7 @@ min_cartesian_tree(const vector& a, root = i; } else if (is_node(i)) { bool le_par = - (l[i] >= 0 && (r[i] == n || a[l[i]] > a[r[i]])); + (l[i] >= 0 && (r[i] == n || a[l[i]] > a[r[i]])); adj[to_min[le_par ? l[i] : r[i]]].push_back(i); } } @@ -40,42 +40,17 @@ void mono_st_asserts(const vector& a) { for (auto cmp : compares) { vector init(n); iota(begin(init), end(init), 0); - RMQ rmq(init, [&](int x, int y) -> int { - return cmp(a[x], a[y]) ? x : y; - }); linear_rmq lin_rmq(a, cmp); auto l = mono_st(a, cmp), r = mono_range(l), p = cart_binary_tree(l); - { - int iterations = 0; - queue> q; - q.push({0, n, -1}); // node_le, node_ri, parent - while (!empty(q)) { - auto [node_le, node_ri, node_par] = q.front(); - q.pop(); - if (node_le == node_ri) continue; - iterations++; - int idx_root = rmq.query(node_le, node_ri); - int idx_root_2 = - lin_rmq.query_idx(node_le, node_ri - 1); - assert(idx_root == idx_root_2); - assert(node_le <= idx_root && idx_root < node_ri); - assert(l[idx_root] == node_le - 1); - assert(r[idx_root] == node_ri); - assert(p[idx_root] == node_par); - q.push({node_le, idx_root, idx_root}); - q.push({idx_root + 1, node_ri, idx_root}); - } - assert(iterations == n); - } { vector old_way_ri = - mono_st({rbegin(a), rend(a)}, - [&](int x, int y) { return !cmp(y, x); }); + mono_st({rbegin(a), rend(a)}, + [&](int x, int y) { return !cmp(y, x); }); reverse(begin(old_way_ri), end(old_way_ri)); transform(begin(old_way_ri), end(old_way_ri), - begin(old_way_ri), - [&](int i) { return sz(a) - i - 1; }); + begin(old_way_ri), + [&](int i) { return sz(a) - i - 1; }); assert(r == old_way_ri); } int iterations = 0; From 32cb033098443afacc5c4dda84c7bb277f9be437 Mon Sep 17 00:00:00 2001 From: GitHub Date: Wed, 11 Dec 2024 03:56:12 +0000 Subject: [PATCH 17/57] [auto-verifier] verify commit ddee6c9cae8c476faa316c54cfe052c0848a6bcb --- .verify-helper/timestamps.remote.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index e6f29880..6c0e6c49 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -37,15 +37,15 @@ "tests/library_checker_aizu_tests/data_structures/persistent_seg_tree.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/data_structures/pq_ds_undo_sliding_window.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/data_structures/pq_ds_undo_with_dsu.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/range_parallel_dsu.test.cpp": "2024-12-10 20:34:52 -0600", "tests/library_checker_aizu_tests/data_structures/rmq_disjoint_sparse_table.test.cpp": "2024-12-10 11:44:08 -0600", "tests/library_checker_aizu_tests/data_structures/rmq_inc.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp": "2024-12-10 11:44:08 -0600", +"tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp": "2024-12-10 21:07:31 -0600", "tests/library_checker_aizu_tests/data_structures/simple_tree.test.cpp": "2024-12-06 01:57:17 -0600", "tests/library_checker_aizu_tests/data_structures/simple_tree_inc.test.cpp": "2024-12-06 01:57:17 -0600", "tests/library_checker_aizu_tests/data_structures/simple_tree_inc_line.test.cpp": "2024-12-06 01:57:17 -0600", "tests/library_checker_aizu_tests/data_structures/simple_tree_line.test.cpp": "2024-12-06 01:57:17 -0600", "tests/library_checker_aizu_tests/flow/dinic_aizu.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/flow/dinic_lib_checker.test.cpp": "2024-12-10 12:20:04 -0600", "tests/library_checker_aizu_tests/flow/hungarian.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/flow/min_cost_max_flow.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/graphs/biconnected_components.test.cpp": "2024-11-17 14:04:03 -0600", @@ -98,7 +98,6 @@ "tests/library_checker_aizu_tests/math/tetration.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/totient.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_binary_tree.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/monotonic_stack_related/max_rect_histogram.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/strings/kmp.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/strings/lcp_query_zfunc.test.cpp": "2024-12-08 12:47:08 -0600", "tests/library_checker_aizu_tests/strings/lcs_dp.test.cpp": "2024-12-05 10:41:42 -0600", From 148b7894e959054307cfcacd8910c34d0a4e4e29 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Thu, 12 Dec 2024 12:25:13 -0600 Subject: [PATCH 18/57] update --- .../data_structures/rmq_linear.test.cpp | 1 + .../{rmq_inc.test.cpp => rmq_sparse_table_inc.test.cpp} | 3 +-- tests/library_checker_aizu_tests/mono_st_asserts.hpp | 6 ------ 3 files changed, 2 insertions(+), 8 deletions(-) rename tests/library_checker_aizu_tests/data_structures/{rmq_inc.test.cpp => rmq_sparse_table_inc.test.cpp} (84%) diff --git a/tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp b/tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp index 22358b00..1d9dba12 100644 --- a/tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp +++ b/tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp @@ -22,6 +22,7 @@ int main() { assert(rmq_less.query(l, r - 1) == a[idx_right_min]); assert(idx_right_min == rmq_greater.query_idx(l, r - 1)); int idx_left_min = rmq_less_equal.query_idx(l, r - 1); + assert(l == idx_left_min || rmq_less_equal.query(l, idx_left_min - 1) > a[idx_left_min]); assert(l <= idx_left_min && idx_left_min < r); assert(idx_left_min == rmq_greater_equal.query_idx(l, r - 1)); assert(a[idx_right_min] == a[idx_left_min]); diff --git a/tests/library_checker_aizu_tests/data_structures/rmq_inc.test.cpp b/tests/library_checker_aizu_tests/data_structures/rmq_sparse_table_inc.test.cpp similarity index 84% rename from tests/library_checker_aizu_tests/data_structures/rmq_inc.test.cpp rename to tests/library_checker_aizu_tests/data_structures/rmq_sparse_table_inc.test.cpp index 2d1f8f29..aca314c6 100644 --- a/tests/library_checker_aizu_tests/data_structures/rmq_inc.test.cpp +++ b/tests/library_checker_aizu_tests/data_structures/rmq_sparse_table_inc.test.cpp @@ -7,8 +7,7 @@ int main() { cin >> n >> q; vector a(n); for (int i = 0; i < n; i++) cin >> a[i]; - rmq_inc rmq(a, - [&](auto& x, auto& y) { return min(x, y); }); + rmq_inc rmq(a, ranges::min); while (q--) { int l, r; cin >> l >> r; diff --git a/tests/library_checker_aizu_tests/mono_st_asserts.hpp b/tests/library_checker_aizu_tests/mono_st_asserts.hpp index 33df6820..35de7063 100644 --- a/tests/library_checker_aizu_tests/mono_st_asserts.hpp +++ b/tests/library_checker_aizu_tests/mono_st_asserts.hpp @@ -2,7 +2,6 @@ #include "../../library/monotonic_stack/monotonic_range.hpp" #include "../../library/monotonic_stack/cartesian_binary_tree.hpp" #include "../../library/monotonic_stack/cartesian_k_ary_tree.hpp" -#include "../../library/data_structures/rmq.hpp" #include "../../library/data_structures/uncommon/linear_rmq.hpp" tuple>, vector> min_cartesian_tree(const vector& a, @@ -38,9 +37,6 @@ void mono_st_asserts(const vector& a) { compares.push_back(greater_equal()); int n = sz(a); for (auto cmp : compares) { - vector init(n); - iota(begin(init), end(init), 0); - linear_rmq lin_rmq(a, cmp); auto l = mono_st(a, cmp), r = mono_range(l), p = cart_binary_tree(l); { @@ -65,8 +61,6 @@ void mono_st_asserts(const vector& a) { assert(cmp(a[i], a[j])); assert(cmp(a[i], a[r[j] - 1])); assert(cmp(a[i], a[j + (r[j] - j) / 2])); - int range_op = a[rmq.query(j, r[j])]; - assert(cmp(a[i], range_op)); iterations++; } } From 8b4c40f5a1fd56b156cfe02b45107d86187b031f Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Thu, 12 Dec 2024 12:41:04 -0600 Subject: [PATCH 19/57] remove test --- .../trees/centroid_decomp_uncommon/lca.hpp | 39 ------------------- .../trees/cd_lca.test.cpp | 26 ------------- 2 files changed, 65 deletions(-) delete mode 100644 library/trees/centroid_decomp_uncommon/lca.hpp delete mode 100644 tests/library_checker_aizu_tests/trees/cd_lca.test.cpp diff --git a/library/trees/centroid_decomp_uncommon/lca.hpp b/library/trees/centroid_decomp_uncommon/lca.hpp deleted file mode 100644 index fe37159f..00000000 --- a/library/trees/centroid_decomp_uncommon/lca.hpp +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once -#include "../centroid_decomp.hpp" -//! https://codeforces.com/blog/entry/81661#comment-686024 -struct cd_lca { - vi d; - vector mn_d, to_cent; - int cmp(int u, int v) { return d[u] < d[v] ? u : v; } - //! @param adj unrooted, undirected tree - //! @time O(n log n) - //! @space O(n log n) for `mn_d` and `to_cent` vectors - cd_lca(const vector& adj): - d(sz(adj)), mn_d(sz(adj)), to_cent(sz(adj)) { - auto dfs_d = [&](auto&& self, int v, int p) -> void { - for (int u : adj[v]) - if (u != p) d[u] = 1 + d[v], self(self, u, v); - }; - dfs_d(dfs_d, 0, -1); - centroid(adj, - [&](const vector& cd_adj, int cent, int) { - auto dfs = [&](auto&& self, int v, int p) -> void { - mn_d[v].push_back( - p == -1 ? v : cmp(mn_d[p].back(), v)); - to_cent[v].push_back(cent); - for (int u : cd_adj[v]) - if (u != p) self(self, u, v); - }; - dfs(dfs, cent, -1); - }); - } - //! @param u,v nodes - //! @returns lca of u, v; where the root is 0 - //! @time O(log(n)) - //! @space O(1) - int lca(int u, int v) { - for (int i = min(sz(mn_d[u]), sz(mn_d[v])) - 1;; i--) - if (to_cent[u][i] == to_cent[v][i]) - return cmp(mn_d[u][i], mn_d[v][i]); - } -}; diff --git a/tests/library_checker_aizu_tests/trees/cd_lca.test.cpp b/tests/library_checker_aizu_tests/trees/cd_lca.test.cpp deleted file mode 100644 index e5a2f72a..00000000 --- a/tests/library_checker_aizu_tests/trees/cd_lca.test.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#define PROBLEM "https://judge.yosupo.jp/problem/lca" -// without this, the test runs in like 34 seconds -#undef _GLIBCXX_DEBUG -#include "../template.hpp" -#include "../cd_asserts.hpp" -#include "../../../library/trees/centroid_decomp_uncommon/lca.hpp" -int main() { - cin.tie(0)->sync_with_stdio(0); - int n, q; - cin >> n >> q; - vector> adj(n); - for (int i = 1; i < n; i++) { - int par; - cin >> par; - adj[par].push_back(i); - adj[i].push_back(par); - } - cd_asserts(adj); - cd_lca lca(adj); - for (int i = 0; i < n; i++) assert(lca.lca(i, i) == i); - while (q--) { - int u, v; - cin >> u >> v; - cout << lca.lca(u, v) << '\n'; - } -} From 7283c15069f84a5c5cd0bad0de25660943c60cfd Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Thu, 12 Dec 2024 12:47:31 -0600 Subject: [PATCH 20/57] fix --- library/trees/subtree_isomorphism.hpp | 31 ++++++++----------- .../trees/subtree_isomorphism.test.cpp | 7 +++-- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/library/trees/subtree_isomorphism.hpp b/library/trees/subtree_isomorphism.hpp index 5b680219..227eb502 100644 --- a/library/trees/subtree_isomorphism.hpp +++ b/library/trees/subtree_isomorphism.hpp @@ -8,21 +8,16 @@ //! isomorphic to subtree v //! @time O(n log n) //! @space O(n) -struct subtree_iso { - int num_distinct_subtrees; - vi iso_id; - subtree_iso(const vector& adj): iso_id(sz(adj), -1) { - map hashes; - auto dfs = [&](auto&& self, int v, int p) -> int { - vi ch_ids; - for (int u : adj[v]) - if (u != p) ch_ids.push_back(self(self, u, v)); - ranges::sort(ch_ids); - return iso_id[v] = - hashes.try_emplace(ch_ids, sz(hashes)) - .first->second; - }; - rep(i, 0, sz(adj)) if (iso_id[i] == -1) dfs(dfs, i, i); - num_distinct_subtrees = sz(hashes); - } -}; +pair subtree_iso(const vector& adj) { + vi iso_id(sz(adj), -1); + map hashes; + auto dfs = [&](auto&& self, int v, int p) -> int { + vi ch_ids; + for (int u : adj[v]) + if (u != p) ch_ids.push_back(self(self, u, v)); + ranges::sort(ch_ids); + return iso_id[v] = hashes.try_emplace(ch_ids, sz(hashes)).first->second; + }; + rep(i, 0, sz(adj)) if (iso_id[i] == -1) dfs(dfs, i, i); + return {sz(hashes), iso_id}; +} diff --git a/tests/library_checker_aizu_tests/trees/subtree_isomorphism.test.cpp b/tests/library_checker_aizu_tests/trees/subtree_isomorphism.test.cpp index 21241b55..73c6322a 100644 --- a/tests/library_checker_aizu_tests/trees/subtree_isomorphism.test.cpp +++ b/tests/library_checker_aizu_tests/trees/subtree_isomorphism.test.cpp @@ -1,5 +1,6 @@ #define PROBLEM \ "https://judge.yosupo.jp/problem/rooted_tree_isomorphism_classification" +#undef _GLIBCXX_DEBUG #include "../template.hpp" #include "../../../library/trees/subtree_isomorphism.hpp" int main() { @@ -18,11 +19,11 @@ int main() { adj_rooted[p].push_back(i); } auto [num_distinct_subtrees, iso_id] = - subtree_iso(adj_unrooted); + subtree_iso(adj_unrooted); auto [num_distinct_subtrees_rooted, iso_id_rooted] = - subtree_iso(adj_rooted); + subtree_iso(adj_rooted); assert( - num_distinct_subtrees == num_distinct_subtrees_rooted); + num_distinct_subtrees == num_distinct_subtrees_rooted); cout << num_distinct_subtrees << '\n'; for (int i = 0; i < n; i++) { cout << iso_id[i] << " "; From a1b1a002d62051b3498c9e3f1175b2212dadb499 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Thu, 12 Dec 2024 12:49:00 -0600 Subject: [PATCH 21/57] add justification --- .../trees/subtree_isomorphism.test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/library_checker_aizu_tests/trees/subtree_isomorphism.test.cpp b/tests/library_checker_aizu_tests/trees/subtree_isomorphism.test.cpp index 73c6322a..d9dbcb82 100644 --- a/tests/library_checker_aizu_tests/trees/subtree_isomorphism.test.cpp +++ b/tests/library_checker_aizu_tests/trees/subtree_isomorphism.test.cpp @@ -1,5 +1,6 @@ #define PROBLEM \ "https://judge.yosupo.jp/problem/rooted_tree_isomorphism_classification" +// as std::map insert takes O(n) time in debug mode #undef _GLIBCXX_DEBUG #include "../template.hpp" #include "../../../library/trees/subtree_isomorphism.hpp" From aef58036ef939ee4ad4406dbd9c88a2785d9a2b0 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Thu, 12 Dec 2024 13:18:52 -0600 Subject: [PATCH 22/57] actually 10 seconds --- .github/workflows/programming_team_code_ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/programming_team_code_ci.yml b/.github/workflows/programming_team_code_ci.yml index cf3c95d2..6ac20d8e 100644 --- a/.github/workflows/programming_team_code_ci.yml +++ b/.github/workflows/programming_team_code_ci.yml @@ -27,7 +27,7 @@ jobs: - name: Run tests env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: oj-verify all --tle 6 --timeout 21600 + run: oj-verify all --tle 10 --timeout 21600 check_format_lint: runs-on: ubuntu-latest From 529e9b13244e767715c8d4d7136b5624818a940f Mon Sep 17 00:00:00 2001 From: GitHub Date: Thu, 12 Dec 2024 20:07:03 +0000 Subject: [PATCH 23/57] [auto-verifier] verify commit aef58036ef939ee4ad4406dbd9c88a2785d9a2b0 --- .verify-helper/timestamps.remote.json | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index 6c0e6c49..f68cac19 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -21,6 +21,7 @@ "tests/library_checker_aizu_tests/data_structures/dsu_bipartite.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/data_structures/dsu_restorable.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/data_structures/dsu_segtree_undo_trick.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/implicit_seg_tree.test.cpp": "2024-12-10 12:06:44 -0600", "tests/library_checker_aizu_tests/data_structures/kruskal_tree_aizu.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/data_structures/kth_smallest_pst.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/data_structures/kth_smallest_wavelet_matrix.test.cpp": "2024-11-19 08:31:51 -0600", @@ -39,8 +40,9 @@ "tests/library_checker_aizu_tests/data_structures/pq_ds_undo_with_dsu.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/data_structures/range_parallel_dsu.test.cpp": "2024-12-10 20:34:52 -0600", "tests/library_checker_aizu_tests/data_structures/rmq_disjoint_sparse_table.test.cpp": "2024-12-10 11:44:08 -0600", -"tests/library_checker_aizu_tests/data_structures/rmq_inc.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp": "2024-12-10 21:07:31 -0600", +"tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp": "2024-12-12 12:25:13 -0600", +"tests/library_checker_aizu_tests/data_structures/rmq_sparse_table.test.cpp": "2024-12-12 12:25:13 -0600", +"tests/library_checker_aizu_tests/data_structures/rmq_sparse_table_inc.test.cpp": "2024-12-12 12:25:13 -0600", "tests/library_checker_aizu_tests/data_structures/simple_tree.test.cpp": "2024-12-06 01:57:17 -0600", "tests/library_checker_aizu_tests/data_structures/simple_tree_inc.test.cpp": "2024-12-06 01:57:17 -0600", "tests/library_checker_aizu_tests/data_structures/simple_tree_inc_line.test.cpp": "2024-12-06 01:57:17 -0600", @@ -84,8 +86,10 @@ "tests/library_checker_aizu_tests/loops/supermasks.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/binary_exponentiation_mod.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/binary_matrix_mult.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/math/count_paths.test.cpp": "2024-12-10 20:34:52 -0600", "tests/library_checker_aizu_tests/math/derangement.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/matrix_determinant.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/math/matrix_mult.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/mod_int_derangement.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/mod_int_gcd_convolution.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/mod_int_n_choose_k.test.cpp": "2024-11-17 14:04:03 -0600", @@ -98,21 +102,33 @@ "tests/library_checker_aizu_tests/math/tetration.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/totient.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_binary_tree.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_k_ary_tree.test.cpp": "2024-12-12 12:25:13 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/count_rectangles.test.cpp": "2024-12-12 12:25:13 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/max_rect_histogram.test.cpp": "2024-12-12 12:25:13 -0600", "tests/library_checker_aizu_tests/strings/kmp.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/strings/lcp_array.test.cpp": "2024-11-22 12:15:07 -0600", +"tests/library_checker_aizu_tests/strings/lcp_query_palindrome.test.cpp": "2024-12-08 12:47:08 -0600", "tests/library_checker_aizu_tests/strings/lcp_query_zfunc.test.cpp": "2024-12-08 12:47:08 -0600", "tests/library_checker_aizu_tests/strings/lcs_dp.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/strings/lcs_queries.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/strings/lcs_queries_merge_sort_tree.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/strings/longest_common_substring.test.cpp": "2024-12-08 12:47:08 -0600", "tests/library_checker_aizu_tests/strings/manacher.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/strings/multi_matching_bs.test.cpp": "2024-12-08 12:47:08 -0600", "tests/library_checker_aizu_tests/strings/prefix_function.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/strings/sa_cmp.test.cpp": "2024-12-08 12:47:08 -0600", "tests/library_checker_aizu_tests/strings/sa_sort_pairs.test.cpp": "2024-12-08 12:47:08 -0600", "tests/library_checker_aizu_tests/strings/single_matching_bs.test.cpp": "2024-12-08 12:47:08 -0600", +"tests/library_checker_aizu_tests/strings/suffix_array.test.cpp": "2024-12-12 12:25:13 -0600", +"tests/library_checker_aizu_tests/strings/suffix_array_short.test.cpp": "2024-11-22 12:15:07 -0600", "tests/library_checker_aizu_tests/strings/trie.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/strings/wildcard_pattern_matching.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/trees/edge_cd_contour_range_query.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/trees/edge_cd_contour_range_update.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/trees/edge_cd_count_paths_per_length.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/trees/ladder_decomposition.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/trees/lca_all_methods_aizu.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/trees/lca_all_methods_lib_checker.test.cpp": "2024-12-05 10:41:42 -0600" +"tests/library_checker_aizu_tests/trees/lca_all_methods_lib_checker.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/trees/subtree_isomorphism.test.cpp": "2024-12-12 12:49:00 -0600" } \ No newline at end of file From 362ed04976e45ccf9b50a0ebef144de608fbad24 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Fri, 13 Dec 2024 12:47:51 -0600 Subject: [PATCH 24/57] split up tests --- ...tion.test.cpp => kth_path_ladder.test.cpp} | 0 .../trees/kth_path_linear.test.cpp | 22 +++++++++++++++++++ ...h.test.cpp => kth_path_tree_lift.test.cpp} | 0 3 files changed, 22 insertions(+) rename tests/library_checker_aizu_tests/trees/{ladder_decomposition.test.cpp => kth_path_ladder.test.cpp} (100%) create mode 100644 tests/library_checker_aizu_tests/trees/kth_path_linear.test.cpp rename tests/library_checker_aizu_tests/trees/{kth_node_on_path.test.cpp => kth_path_tree_lift.test.cpp} (100%) diff --git a/tests/library_checker_aizu_tests/trees/ladder_decomposition.test.cpp b/tests/library_checker_aizu_tests/trees/kth_path_ladder.test.cpp similarity index 100% rename from tests/library_checker_aizu_tests/trees/ladder_decomposition.test.cpp rename to tests/library_checker_aizu_tests/trees/kth_path_ladder.test.cpp diff --git a/tests/library_checker_aizu_tests/trees/kth_path_linear.test.cpp b/tests/library_checker_aizu_tests/trees/kth_path_linear.test.cpp new file mode 100644 index 00000000..45137de3 --- /dev/null +++ b/tests/library_checker_aizu_tests/trees/kth_path_linear.test.cpp @@ -0,0 +1,22 @@ +#define PROBLEM \ + "https://judge.yosupo.jp/problem/jump_on_tree" +#include "../template.hpp" +#include "../../../library/trees/linear_kth_path.hpp" +int main() { + cin.tie(0)->sync_with_stdio(0); + int n, q; + cin >> n >> q; + vector> adj(n); + for (int i = 0; i < n - 1; i++) { + int u, v; + cin >> u >> v; + adj[u].push_back(v); + adj[v].push_back(u); + } + linear_kth_path lin_kth_path(adj); + while (q--) { + int u, v, k; + cin >> u >> v >> k; + cout << lin_kth_path.kth_path(u, v, k) << '\n'; + } +} diff --git a/tests/library_checker_aizu_tests/trees/kth_node_on_path.test.cpp b/tests/library_checker_aizu_tests/trees/kth_path_tree_lift.test.cpp similarity index 100% rename from tests/library_checker_aizu_tests/trees/kth_node_on_path.test.cpp rename to tests/library_checker_aizu_tests/trees/kth_path_tree_lift.test.cpp From 964097a0ef624ad66f2ac9aedbec2e9579d72611 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Fri, 13 Dec 2024 12:53:13 -0600 Subject: [PATCH 25/57] shorten other test --- .../trees/kth_path_linear.test.cpp | 4 +++ .../trees/kth_path_tree_lift.test.cpp | 35 +++---------------- 2 files changed, 9 insertions(+), 30 deletions(-) diff --git a/tests/library_checker_aizu_tests/trees/kth_path_linear.test.cpp b/tests/library_checker_aizu_tests/trees/kth_path_linear.test.cpp index 45137de3..40055b99 100644 --- a/tests/library_checker_aizu_tests/trees/kth_path_linear.test.cpp +++ b/tests/library_checker_aizu_tests/trees/kth_path_linear.test.cpp @@ -2,6 +2,8 @@ "https://judge.yosupo.jp/problem/jump_on_tree" #include "../template.hpp" #include "../../../library/trees/linear_kth_path.hpp" +#include "../../../library/trees/lca_rmq/lca_rmq.hpp" +#include "../compress_tree_asserts.hpp" int main() { cin.tie(0)->sync_with_stdio(0); int n, q; @@ -14,6 +16,8 @@ int main() { adj[v].push_back(u); } linear_kth_path lin_kth_path(adj); + LCA lc(adj); + compress_tree_asserts(adj, lc); while (q--) { int u, v, k; cin >> u >> v >> k; diff --git a/tests/library_checker_aizu_tests/trees/kth_path_tree_lift.test.cpp b/tests/library_checker_aizu_tests/trees/kth_path_tree_lift.test.cpp index 5f8deff7..9a656f62 100644 --- a/tests/library_checker_aizu_tests/trees/kth_path_tree_lift.test.cpp +++ b/tests/library_checker_aizu_tests/trees/kth_path_tree_lift.test.cpp @@ -2,12 +2,8 @@ "https://judge.yosupo.jp/problem/jump_on_tree" #include "../template.hpp" #include "../../../library/contest/random.hpp" -#include "../../../library/monotonic_stack/monotonic_stack.hpp" #include "../../../library/trees/tree_lift/tree_lift.hpp" #include "../../../library/trees/lca_rmq/lca_rmq.hpp" -#include "../../../library/trees/linear_lca.hpp" -#include "../../../library/trees/linear_kth_path.hpp" -#include "../compress_tree_asserts.hpp" int main() { cin.tie(0)->sync_with_stdio(0); int n, q; @@ -21,42 +17,21 @@ int main() { } tree_lift tl(adj); LCA lc(adj); - linear_kth_path lin_kth_path(adj); - compress_tree_asserts(adj, lc); while (q--) { int u, v, k; cin >> u >> v >> k; int dist_in_edges = tl.dist_edges(u, v); assert(dist_in_edges == lc.dist_edges(u, v)); - assert(dist_in_edges == - lin_kth_path.lin_lca.dist_edges(u, v)); - int res = tl.kth_path(u, v, k); - assert(res == lin_kth_path.kth_path(u, v, k)); - cout << res << '\n'; + cout << tl.kth_path(u, v, k) << '\n'; { int w = rnd(0, n - 1); assert(lc.on_path(u, v, w) == - (lc.dist_edges(u, w) + lc.dist_edges(w, v) == - lc.dist_edges(u, v))); + (lc.dist_edges(u, w) + lc.dist_edges(w, v) == + lc.dist_edges(u, v))); } if (u != v) { - assert(tl.kth_path(u, v, 0) == u); - assert(lin_kth_path.kth_path(u, v, 0) == u); - assert( - tl.kth_path(u, v, 1) == lc.next_on_path(u, v)); - assert(lin_kth_path.kth_path(u, v, 1) == - lc.next_on_path(u, v)); - assert(tl.kth_path(u, v, dist_in_edges - 1) == - lc.next_on_path(v, u)); - assert( - lin_kth_path.kth_path(u, v, dist_in_edges - 1) == - lc.next_on_path(v, u)); - assert(tl.kth_path(u, v, dist_in_edges) == v); - assert( - lin_kth_path.kth_path(u, v, dist_in_edges) == v); - assert(tl.kth_path(u, v, dist_in_edges + 1) == -1); - assert(lin_kth_path.kth_path(u, v, - dist_in_edges + 1) == -1); + assert(tl.kth_path(u, v, 1) == lc.next_on_path(u, v)); + assert(tl.kth_path(u, v, dist_in_edges - 1) == lc.next_on_path(v, u)); } } } From 0c9455fbdba944c4dbcb6001dc59c0d5fdcab45a Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Fri, 13 Dec 2024 12:59:54 -0600 Subject: [PATCH 26/57] move speed test to edge CD --- .../trees/count_paths_per_length.test.cpp | 10 ---------- .../trees/edge_cd_count_paths_per_length.test.cpp | 9 +++++++++ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/tests/library_checker_aizu_tests/trees/count_paths_per_length.test.cpp b/tests/library_checker_aizu_tests/trees/count_paths_per_length.test.cpp index a7aad051..717eea89 100644 --- a/tests/library_checker_aizu_tests/trees/count_paths_per_length.test.cpp +++ b/tests/library_checker_aizu_tests/trees/count_paths_per_length.test.cpp @@ -2,8 +2,6 @@ "https://judge.yosupo.jp/problem/frequency_table_of_tree_distance" #include "../template.hpp" #include "../cd_asserts.hpp" -#include "../../../library/contest/random.hpp" -#include "../../../library/trees/centroid_decomp_uncommon/count_paths_per_node.hpp" #include "../../../library/trees/centroid_decomp_uncommon/count_paths_per_length.hpp" int main() { cin.tie(0)->sync_with_stdio(0); @@ -18,14 +16,6 @@ int main() { } cd_asserts(adj); vector cnt_len = count_paths_per_length(adj); - if (n >= 2) { - int k = rnd(1, n - 1); - vector count_paths = count_paths_per_node(adj, k); - ll sum = accumulate(begin(count_paths), - end(count_paths), 0LL); - assert(sum % (k + 1) == 0); - assert(sum / (k + 1) == cnt_len[k]); - } for (int i = 1; i < n; i++) cout << cnt_len[i] << " "; cout << '\n'; return 0; diff --git a/tests/library_checker_aizu_tests/trees/edge_cd_count_paths_per_length.test.cpp b/tests/library_checker_aizu_tests/trees/edge_cd_count_paths_per_length.test.cpp index 4ca0428a..46cb745a 100644 --- a/tests/library_checker_aizu_tests/trees/edge_cd_count_paths_per_length.test.cpp +++ b/tests/library_checker_aizu_tests/trees/edge_cd_count_paths_per_length.test.cpp @@ -3,6 +3,8 @@ #include "../template.hpp" #include "../edge_cd_asserts.hpp" #include "../../../library/trees/edge_centroid_decomp_uncommon/count_paths_per_length.hpp" +#include "../../../library/contest/random.hpp" +#include "../../../library/trees/centroid_decomp_uncommon/count_paths_per_node.hpp" int main() { cin.tie(0)->sync_with_stdio(0); int n; @@ -16,6 +18,13 @@ int main() { } { edge_cd(adj, edge_cd_asserts); } vector cnt_len = count_paths_per_length(adj); + if (n >= 2) { + int k = rnd(1, n - 1); + vector count_paths = count_paths_per_node(adj, k); + ll sum = accumulate(begin(count_paths), end(count_paths), 0LL); + assert(sum % (k + 1) == 0); + assert(sum / (k + 1) == cnt_len[k]); + } for (int i = 1; i < n; i++) cout << cnt_len[i] << " "; cout << '\n'; return 0; From f5ff9d2f1bf1bf268d8a878b2d1924c653801eb7 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Fri, 13 Dec 2024 13:06:55 -0600 Subject: [PATCH 27/57] add assert for par of centroid tree --- .../library_checker_aizu_tests/cd_asserts.hpp | 41 +++++----- .../trees/cd_jump_on_tree.test.cpp | 78 ------------------- 2 files changed, 22 insertions(+), 97 deletions(-) delete mode 100644 tests/library_checker_aizu_tests/trees/cd_jump_on_tree.test.cpp diff --git a/tests/library_checker_aizu_tests/cd_asserts.hpp b/tests/library_checker_aizu_tests/cd_asserts.hpp index 440abd69..596f1b8b 100644 --- a/tests/library_checker_aizu_tests/cd_asserts.hpp +++ b/tests/library_checker_aizu_tests/cd_asserts.hpp @@ -2,25 +2,28 @@ #include "../../library/trees/centroid_decomp.hpp" void cd_asserts(const vector>& adj) { vector decomp_size(sz(adj), -1); + vector naive_par_decomp(sz(adj), -1); centroid(adj, - [&](const vector>& cd_adj, int cent, - int par_cent) -> void { - assert(decomp_size[cent] == -1); - auto dfs = [&](auto&& self, int u, int p) -> int { - int sub_size = 1; - for (int v : cd_adj[u]) - if (v != p) sub_size += self(self, v, u); - return sub_size; - }; - decomp_size[cent] = dfs(dfs, cent, -1); - if (par_cent != -1) - assert(1 <= decomp_size[cent] && - 2 * decomp_size[cent] <= decomp_size[par_cent]); - for (int u : cd_adj[cent]) { - int sz_subtree = dfs(dfs, u, cent); - assert(1 <= sz_subtree && - 2 * sz_subtree <= decomp_size[cent]); - } - }); + [&](const vector>& cd_adj, int cent, + int par_cent) -> void { + assert(naive_par_decomp[cent] == par_cent); + assert(decomp_size[cent] == -1); + auto dfs = [&](auto&& self, int u, int p) -> int { + naive_par_decomp[u] = cent; + int sub_size = 1; + for (int v : cd_adj[u]) + if (v != p) sub_size += self(self, v, u); + return sub_size; + }; + decomp_size[cent] = dfs(dfs, cent, -1); + if (par_cent != -1) + assert(1 <= decomp_size[cent] && + 2 * decomp_size[cent] <= decomp_size[par_cent]); + for (int u : cd_adj[cent]) { + int sz_subtree = dfs(dfs, u, cent); + assert(1 <= sz_subtree && + 2 * sz_subtree <= decomp_size[cent]); + } + }); rep(i, 0, sz(adj)) assert(decomp_size[i] >= 1); } diff --git a/tests/library_checker_aizu_tests/trees/cd_jump_on_tree.test.cpp b/tests/library_checker_aizu_tests/trees/cd_jump_on_tree.test.cpp deleted file mode 100644 index 8638c6d9..00000000 --- a/tests/library_checker_aizu_tests/trees/cd_jump_on_tree.test.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#define PROBLEM \ - "https://judge.yosupo.jp/problem/jump_on_tree" -#include "../template.hpp" -#include "../cd_asserts.hpp" -#include "../../../library/trees/centroid_decomp.hpp" -int main() { - cin.tie(0)->sync_with_stdio(0); - int n, q; - cin >> n >> q; - vector> adj(n); - for (int i = 0; i < n - 1; i++) { - int u, v; - cin >> u >> v; - adj[u].push_back(v); - adj[v].push_back(u); - } - cd_asserts(adj); - vector cent_par(n), cent_depth(n); - vector> c_depth(n); - centroid(adj, - [&](const vector& cent_adj, int cent, - int par_cent) { - cent_par[cent] = par_cent; - if (par_cent != -1) - cent_depth[cent] = 1 + cent_depth[par_cent]; - auto dfs = [&](auto&& self, int v, int p, - int d) -> void { - c_depth[v].push_back(d); - for (int ch : cent_adj[v]) { - if (ch == p) continue; - self(self, ch, v, d + 1); - } - }; - dfs(dfs, cent, -1, 0); - }); - vector>> queries(n); - vector res(q); - for (int q_idx = 0; q_idx < q; q_idx++) { - int s, t, i; - cin >> s >> t >> i; - int u = s, v = t; - while (u != v) - if (cent_depth[u] > cent_depth[v]) u = cent_par[u]; - else v = cent_par[v]; - int lca_d = cent_depth[u]; - if (i > c_depth[s][lca_d] + c_depth[t][lca_d]) - res[q_idx] = -1; - else if (i < c_depth[s][lca_d]) { - queries[s].push_back({lca_d, i, q_idx}); - } else { - queries[t].push_back({lca_d, - c_depth[s][lca_d] + c_depth[t][lca_d] - i, q_idx}); - } - } - for (int i = 0; i < n; i++) - sort(begin(queries[i]), end(queries[i])); - vector pos(n); - centroid(adj, - [&](const vector& cent_adj, int cent, int) { - vector st; - auto dfs = [&](auto&& self, int v, int p) -> void { - st.push_back(v); - while (pos[v] < sz(queries[v]) && - queries[v][pos[v]][0] == cent_depth[cent]) { - auto [_, k, q_idx] = queries[v][pos[v]]; - res[q_idx] = st[sz(st) - 1 - k]; - pos[v]++; - } - for (int ch : cent_adj[v]) { - if (ch == p) continue; - self(self, ch, v); - } - st.pop_back(); - }; - dfs(dfs, cent, -1); - }); - for (int i = 0; i < q; i++) cout << res[i] << '\n'; -} From 211497f506ed3c22bfa65d7d248eb68af7266755 Mon Sep 17 00:00:00 2001 From: GitHub Date: Fri, 13 Dec 2024 19:28:28 +0000 Subject: [PATCH 28/57] [auto-verifier] verify commit f5ff9d2f1bf1bf268d8a878b2d1924c653801eb7 --- .verify-helper/timestamps.remote.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index f68cac19..b11d2cb3 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -125,9 +125,10 @@ "tests/library_checker_aizu_tests/strings/wildcard_pattern_matching.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/trees/edge_cd_contour_range_query.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/trees/edge_cd_contour_range_update.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/trees/edge_cd_count_paths_per_length.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/trees/ladder_decomposition.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/trees/kth_path_ladder.test.cpp": "2024-12-13 12:47:51 -0600", +"tests/library_checker_aizu_tests/trees/kth_path_linear.test.cpp": "2024-12-13 12:53:13 -0600", +"tests/library_checker_aizu_tests/trees/kth_path_tree_lift.test.cpp": "2024-12-13 12:53:13 -0600", "tests/library_checker_aizu_tests/trees/lca_all_methods_aizu.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/trees/lca_all_methods_lib_checker.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/trees/subtree_isomorphism.test.cpp": "2024-12-12 12:49:00 -0600" From 9b394185a7934a669f3a0fa9491b311b1896c908 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Fri, 13 Dec 2024 15:18:46 -0600 Subject: [PATCH 29/57] remove cd asserts --- .../offline_incremental_scc.hpp | 15 ++--- .../count_paths_per_length.hpp | 58 +++++++++---------- .../trees/count_paths_per_length.test.cpp | 2 - .../edge_cd_count_paths_per_length.test.cpp | 9 --- 4 files changed, 34 insertions(+), 50 deletions(-) diff --git a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp index 98971c67..4fbc53d5 100644 --- a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp +++ b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp @@ -13,26 +13,25 @@ vi offline_incremental_scc(vector> eds, int n) { int m = sz(eds); - vi ids(n, -1), joins(m, m), idx(m); + vi ids(n, -1), joins(m, m), idx(m), vs(n), scc_id; iota(all(idx), 0); auto divide_and_conquer = [&](auto&& self, auto el, auto er, int tl, int tr) { - int mid = midpoint(tl, tr); - vi vs; + int mid = midpoint(tl, tr), p = 0; vector adj; for (auto it = el; it != er; it++) { auto& [u, v] = eds[*it]; for (int w : {u, v}) { if (ids[w] != -1) continue; - ids[w] = sz(vs); - vs.push_back(w); + ids[w] = p; + vs[p++] = w; adj.emplace_back(); } u = ids[u], v = ids[v]; if (*it <= mid) adj[u].push_back(v); } - for (int v : vs) ids[v] = -1; - auto scc_id = sccs(adj).scc_id; + rep(i, 0, p) ids[vs[i]] = -1; + scc_id = sccs(adj).scc_id; auto split = partition(el, er, [&](int i) { return scc_id[eds[i][0]] == scc_id[eds[i][1]]; }); @@ -43,9 +42,7 @@ vi offline_incremental_scc(vector> eds, u = scc_id[u], v = scc_id[v]; } // deallocate to avoid O(m log m) memory - vi().swap(vs); vector().swap(adj); - vi().swap(scc_id); self(self, el, split, tl, mid); self(self, split, er, mid, tr); }; diff --git a/library/trees/centroid_decomp_uncommon/count_paths_per_length.hpp b/library/trees/centroid_decomp_uncommon/count_paths_per_length.hpp index ebe111ce..8e59e156 100644 --- a/library/trees/centroid_decomp_uncommon/count_paths_per_length.hpp +++ b/library/trees/centroid_decomp_uncommon/count_paths_per_length.hpp @@ -10,35 +10,33 @@ vector count_paths_per_length(const vector& adj) { vector num_paths(sz(adj)); centroid(adj, - [&](const vector& cd_adj, int cent, int) { - vector> child_depths; - for (int v : cd_adj[cent]) { - child_depths.emplace_back(1, 0.0); - for (queue q({{v, cent}}); !empty(q);) { - child_depths.back().push_back(sz(q)); - queue new_q; - while (!empty(q)) { - auto [u, p] = q.front(); - q.pop(); - for (int w : cd_adj[u]) { - if (w == p) continue; - new_q.emplace(w, u); - } - } - swap(q, new_q); - } - } - ranges::sort(child_depths, - [&](auto& x, auto& y) { return sz(x) < sz(y); }); - vector total_depth(1, 1.0); - for (auto& cnt_depth : child_depths) { - auto prod = conv(total_depth, cnt_depth); - rep(i, 1, sz(prod)) num_paths[i] += - llround(prod[i]); - total_depth.resize(sz(cnt_depth)); - rep(i, 1, sz(cnt_depth)) total_depth[i] += - cnt_depth[i]; - } - }); + [&](const vector& cd_adj, int cent, int) { + vector> child_depths; + for (int v : cd_adj[cent]) { + child_depths.emplace_back(1, 0.0); + for (queue q({{v, cent}}); !empty(q);) { + child_depths.back().push_back(sz(q)); + queue new_q; + while (!empty(q)) { + auto [u, p] = q.front(); + q.pop(); + for (int w : cd_adj[u]) { + if (w == p) continue; + new_q.emplace(w, u); + } + } + swap(q, new_q); + } + } + ranges::sort(child_depths, {}, [&](auto& x) { return sz(x); }); + vector total_depth(1, 1.0); + for (auto& cnt_depth : child_depths) { + auto prod = conv(total_depth, cnt_depth); + rep(i, 1, sz(prod)) num_paths[i] += llround(prod[i]); + total_depth.resize(sz(cnt_depth)); + rep(i, 1, sz(cnt_depth)) total_depth[i] += + cnt_depth[i]; + } + }); return num_paths; } diff --git a/tests/library_checker_aizu_tests/trees/count_paths_per_length.test.cpp b/tests/library_checker_aizu_tests/trees/count_paths_per_length.test.cpp index 717eea89..d1e32efb 100644 --- a/tests/library_checker_aizu_tests/trees/count_paths_per_length.test.cpp +++ b/tests/library_checker_aizu_tests/trees/count_paths_per_length.test.cpp @@ -1,7 +1,6 @@ #define PROBLEM \ "https://judge.yosupo.jp/problem/frequency_table_of_tree_distance" #include "../template.hpp" -#include "../cd_asserts.hpp" #include "../../../library/trees/centroid_decomp_uncommon/count_paths_per_length.hpp" int main() { cin.tie(0)->sync_with_stdio(0); @@ -14,7 +13,6 @@ int main() { adj[u].push_back(v); adj[v].push_back(u); } - cd_asserts(adj); vector cnt_len = count_paths_per_length(adj); for (int i = 1; i < n; i++) cout << cnt_len[i] << " "; cout << '\n'; diff --git a/tests/library_checker_aizu_tests/trees/edge_cd_count_paths_per_length.test.cpp b/tests/library_checker_aizu_tests/trees/edge_cd_count_paths_per_length.test.cpp index 46cb745a..4ca0428a 100644 --- a/tests/library_checker_aizu_tests/trees/edge_cd_count_paths_per_length.test.cpp +++ b/tests/library_checker_aizu_tests/trees/edge_cd_count_paths_per_length.test.cpp @@ -3,8 +3,6 @@ #include "../template.hpp" #include "../edge_cd_asserts.hpp" #include "../../../library/trees/edge_centroid_decomp_uncommon/count_paths_per_length.hpp" -#include "../../../library/contest/random.hpp" -#include "../../../library/trees/centroid_decomp_uncommon/count_paths_per_node.hpp" int main() { cin.tie(0)->sync_with_stdio(0); int n; @@ -18,13 +16,6 @@ int main() { } { edge_cd(adj, edge_cd_asserts); } vector cnt_len = count_paths_per_length(adj); - if (n >= 2) { - int k = rnd(1, n - 1); - vector count_paths = count_paths_per_node(adj, k); - ll sum = accumulate(begin(count_paths), end(count_paths), 0LL); - assert(sum % (k + 1) == 0); - assert(sum / (k + 1) == cnt_len[k]); - } for (int i = 1; i < n; i++) cout << cnt_len[i] << " "; cout << '\n'; return 0; From b67c8fda3e3cb0db12dec2e0aa4a0976f2dc1bc8 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Fri, 13 Dec 2024 15:23:04 -0600 Subject: [PATCH 30/57] add cd asserts here at least --- .../handmade_tests/count_paths_forest.test.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/library_checker_aizu_tests/handmade_tests/count_paths_forest.test.cpp b/tests/library_checker_aizu_tests/handmade_tests/count_paths_forest.test.cpp index 7a047167..d80d07c4 100644 --- a/tests/library_checker_aizu_tests/handmade_tests/count_paths_forest.test.cpp +++ b/tests/library_checker_aizu_tests/handmade_tests/count_paths_forest.test.cpp @@ -6,8 +6,9 @@ #include "../../../library/data_structures/dsu/dsu_restorable.hpp" #include "../../../library/trees/tree_lift/tree_lift.hpp" #include "../../../library/trees/centroid_decomp_uncommon/count_paths_per_length.hpp" +#include "../cd_asserts.hpp" vector> naive(const vector>& adj, - dsu_restorable& dsu) { + dsu_restorable& dsu) { tree_lift tl(adj); int n = sz(adj); vector> cnts_naive(n + 1, vector(n, 0)); @@ -37,16 +38,17 @@ int main() { adj[v].push_back(u); } } + cd_asserts(adj); vector> cnts_naive = naive(adj, dsu); for (int k = 1; k <= n; k++) assert( - count_paths_per_node(adj, k) == cnts_naive[k]); + count_paths_per_node(adj, k) == cnts_naive[k]); vector num_paths_len = count_paths_per_length(adj); for (int k = 1; k < n; k++) { vector count_paths = - count_paths_per_node(adj, k); + count_paths_per_node(adj, k); ll total_paths = accumulate(begin(count_paths), - end(count_paths), 0LL); + end(count_paths), 0LL); assert(total_paths % (k + 1) == 0); total_paths /= k + 1; assert(num_paths_len[k] == total_paths); From eeb24afb4a6782a6c3f89f9916d007d391882748 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Fri, 13 Dec 2024 15:30:48 -0600 Subject: [PATCH 31/57] speedup --- .../offline_incremental_scc.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp index 4fbc53d5..0168a583 100644 --- a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp +++ b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp @@ -15,10 +15,10 @@ vi offline_incremental_scc(vector> eds, int m = sz(eds); vi ids(n, -1), joins(m, m), idx(m), vs(n), scc_id; iota(all(idx), 0); + vector adj; auto divide_and_conquer = [&](auto&& self, auto el, auto er, int tl, int tr) { int mid = midpoint(tl, tr), p = 0; - vector adj; for (auto it = el; it != er; it++) { auto& [u, v] = eds[*it]; for (int w : {u, v}) { @@ -32,6 +32,7 @@ vi offline_incremental_scc(vector> eds, } rep(i, 0, p) ids[vs[i]] = -1; scc_id = sccs(adj).scc_id; + adj.clear(); auto split = partition(el, er, [&](int i) { return scc_id[eds[i][0]] == scc_id[eds[i][1]]; }); @@ -41,8 +42,6 @@ vi offline_incremental_scc(vector> eds, auto& [u, v] = eds[*it]; u = scc_id[u], v = scc_id[v]; } - // deallocate to avoid O(m log m) memory - vector().swap(adj); self(self, el, split, tl, mid); self(self, split, er, mid, tr); }; From 2d56da51e435801417c9a78fb6d0d7e413322a28 Mon Sep 17 00:00:00 2001 From: GitHub Date: Fri, 13 Dec 2024 21:50:32 +0000 Subject: [PATCH 32/57] [auto-verifier] verify commit eeb24afb4a6782a6c3f89f9916d007d391882748 --- .verify-helper/timestamps.remote.json | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index b11d2cb3..5ae064cd 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -54,15 +54,15 @@ "tests/library_checker_aizu_tests/graphs/connected_components_of_complement_graph.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/graphs/dijkstra_aizu.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/graphs/dijkstra_lib_checker.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/graphs/directed_cycle.test.cpp": "2024-12-10 12:26:47 -0600", +"tests/library_checker_aizu_tests/graphs/directed_cycle.test.cpp": "2024-12-13 15:30:48 -0600", "tests/library_checker_aizu_tests/graphs/enumerate_triangles.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/graphs/hopcroft_karp_aizu.test.cpp": "2024-11-19 11:51:33 -0600", "tests/library_checker_aizu_tests/graphs/hopcroft_karp_lib_checker.test.cpp": "2024-11-19 11:51:33 -0600", "tests/library_checker_aizu_tests/graphs/mst.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp": "2024-12-10 12:26:47 -0600", -"tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp": "2024-12-10 12:26:47 -0600", +"tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp": "2024-12-13 15:30:48 -0600", +"tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp": "2024-12-13 15:30:48 -0600", "tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/handmade_tests/count_paths_forest.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/handmade_tests/count_paths_forest.test.cpp": "2024-12-13 15:23:04 -0600", "tests/library_checker_aizu_tests/handmade_tests/dsu_size.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/handmade_tests/dynamic_bitset.test.cpp": "2024-11-22 10:47:44 -0600", "tests/library_checker_aizu_tests/handmade_tests/edge_cd_small_trees.test.cpp": "2024-12-10 12:27:45 -0600", @@ -123,8 +123,10 @@ "tests/library_checker_aizu_tests/strings/suffix_array_short.test.cpp": "2024-11-22 12:15:07 -0600", "tests/library_checker_aizu_tests/strings/trie.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/strings/wildcard_pattern_matching.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/trees/count_paths_per_length.test.cpp": "2024-12-13 15:18:46 -0600", "tests/library_checker_aizu_tests/trees/edge_cd_contour_range_query.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/trees/edge_cd_contour_range_update.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/trees/edge_cd_count_paths_per_length.test.cpp": "2024-12-13 15:18:46 -0600", "tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/trees/kth_path_ladder.test.cpp": "2024-12-13 12:47:51 -0600", "tests/library_checker_aizu_tests/trees/kth_path_linear.test.cpp": "2024-12-13 12:53:13 -0600", From c2143142bb9b8cc5649a6221d4d1ef973b84059d Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Fri, 13 Dec 2024 16:03:58 -0600 Subject: [PATCH 33/57] remove var --- .../offline_incremental_scc.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp index 0168a583..6cec8bbd 100644 --- a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp +++ b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp @@ -18,21 +18,21 @@ vi offline_incremental_scc(vector> eds, vector adj; auto divide_and_conquer = [&](auto&& self, auto el, auto er, int tl, int tr) { - int mid = midpoint(tl, tr), p = 0; + adj.clear(); + int mid = midpoint(tl, tr); for (auto it = el; it != er; it++) { auto& [u, v] = eds[*it]; for (int w : {u, v}) { if (ids[w] != -1) continue; - ids[w] = p; - vs[p++] = w; + ids[w] = sz(adj); + vs[sz(adj)] = w; adj.emplace_back(); } u = ids[u], v = ids[v]; if (*it <= mid) adj[u].push_back(v); } - rep(i, 0, p) ids[vs[i]] = -1; + rep(i, 0, sz(adj)) ids[vs[i]] = -1; scc_id = sccs(adj).scc_id; - adj.clear(); auto split = partition(el, er, [&](int i) { return scc_id[eds[i][0]] == scc_id[eds[i][1]]; }); From 55404815e76c1d81d1bb1594a9f53d53413c5d23 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Fri, 13 Dec 2024 16:14:15 -0600 Subject: [PATCH 34/57] trying some optimizations --- .../offline_incremental_scc.hpp | 34 +++++++++---------- .../graphs/offline_incremental_scc.test.cpp | 1 - .../math/xor_basis_intersection.test.cpp | 5 +-- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp index 6cec8bbd..e1bb440c 100644 --- a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp +++ b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp @@ -16,30 +16,28 @@ vi offline_incremental_scc(vector> eds, vi ids(n, -1), joins(m, m), idx(m), vs(n), scc_id; iota(all(idx), 0); vector adj; - auto divide_and_conquer = [&](auto&& self, auto el, - auto er, int tl, int tr) { + auto divide_and_conquer = [&](auto&& self, int el, + int er, int tl, int tr) { adj.clear(); int mid = midpoint(tl, tr); - for (auto it = el; it != er; it++) { - auto& [u, v] = eds[*it]; - for (int w : {u, v}) { - if (ids[w] != -1) continue; - ids[w] = sz(adj); - vs[sz(adj)] = w; - adj.emplace_back(); - } + rep(i, el, er) { + auto& [u, v] = eds[idx[i]]; + for (int w : {u, v}) + if (ids[w] == -1) { + ids[w] = sz(adj); + vs[sz(adj)] = w; + adj.emplace_back(); + } u = ids[u], v = ids[v]; - if (*it <= mid) adj[u].push_back(v); + if (idx[i] <= mid) adj[u].push_back(v); } rep(i, 0, sz(adj)) ids[vs[i]] = -1; scc_id = sccs(adj).scc_id; - auto split = partition(el, er, [&](int i) { - return scc_id[eds[i][0]] == scc_id[eds[i][1]]; - }); - for (auto it = el; it != split; it++) joins[*it] = mid; + int split = partition(begin(idx) + el, begin(idx) + er, [&](int i) { return scc_id[eds[i][0]] == scc_id[eds[i][1]]; }) - begin(idx); + rep(i, el, split) joins[idx[i]] = mid; if (tr - tl == 1) return; - for (auto it = split; it != er; it++) { - auto& [u, v] = eds[*it]; + rep(i, split, er) { + auto& [u, v] = eds[idx[i]]; u = scc_id[u], v = scc_id[v]; } self(self, el, split, tl, mid); @@ -47,6 +45,6 @@ vi offline_incremental_scc(vector> eds, }; // uses -1 as the lower bound to correctly handle // self-edges - divide_and_conquer(divide_and_conquer, all(idx), -1, m); + divide_and_conquer(divide_and_conquer, 0, m, -1, m); return joins; } diff --git a/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp b/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp index a7e3a2b5..5dc99538 100644 --- a/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp +++ b/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp @@ -13,7 +13,6 @@ int main() { vector> eds(m); for (auto& [u, v] : eds) cin >> u >> v; auto joins = offline_incremental_scc(eds, n); - // assert joins[i] == -1 for self-edges for (int t = 0; t < m; t++) assert((eds[t][0] == eds[t][1]) == (joins[t] == -1)); vector order(m); diff --git a/tests/library_checker_aizu_tests/math/xor_basis_intersection.test.cpp b/tests/library_checker_aizu_tests/math/xor_basis_intersection.test.cpp index 8f88b24a..44239449 100644 --- a/tests/library_checker_aizu_tests/math/xor_basis_intersection.test.cpp +++ b/tests/library_checker_aizu_tests/math/xor_basis_intersection.test.cpp @@ -17,10 +17,11 @@ int main() { cin.tie(0)->sync_with_stdio(0); int t; cin >> t; + basis basis1, basis2; while (t--) { int n; cin >> n; - basis basis1; + basis1.b.clear(); for (int i = 0; i < n; i++) { int val; cin >> val; @@ -29,7 +30,7 @@ int main() { check_condition(basis1); int m; cin >> m; - basis basis2; + basis2.b.clear(); for (int j = 0; j < m; j++) { int val; cin >> val; From 4a69b0851e39cf2128b0335f099ec8934b92c9cc Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Fri, 13 Dec 2024 16:16:45 -0600 Subject: [PATCH 35/57] Revert "trying some optimizations" This reverts commit 55404815e76c1d81d1bb1594a9f53d53413c5d23. --- .../offline_incremental_scc.hpp | 34 ++++++++++--------- .../graphs/offline_incremental_scc.test.cpp | 1 + .../math/xor_basis_intersection.test.cpp | 5 ++- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp index e1bb440c..6cec8bbd 100644 --- a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp +++ b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp @@ -16,28 +16,30 @@ vi offline_incremental_scc(vector> eds, vi ids(n, -1), joins(m, m), idx(m), vs(n), scc_id; iota(all(idx), 0); vector adj; - auto divide_and_conquer = [&](auto&& self, int el, - int er, int tl, int tr) { + auto divide_and_conquer = [&](auto&& self, auto el, + auto er, int tl, int tr) { adj.clear(); int mid = midpoint(tl, tr); - rep(i, el, er) { - auto& [u, v] = eds[idx[i]]; - for (int w : {u, v}) - if (ids[w] == -1) { - ids[w] = sz(adj); - vs[sz(adj)] = w; - adj.emplace_back(); - } + for (auto it = el; it != er; it++) { + auto& [u, v] = eds[*it]; + for (int w : {u, v}) { + if (ids[w] != -1) continue; + ids[w] = sz(adj); + vs[sz(adj)] = w; + adj.emplace_back(); + } u = ids[u], v = ids[v]; - if (idx[i] <= mid) adj[u].push_back(v); + if (*it <= mid) adj[u].push_back(v); } rep(i, 0, sz(adj)) ids[vs[i]] = -1; scc_id = sccs(adj).scc_id; - int split = partition(begin(idx) + el, begin(idx) + er, [&](int i) { return scc_id[eds[i][0]] == scc_id[eds[i][1]]; }) - begin(idx); - rep(i, el, split) joins[idx[i]] = mid; + auto split = partition(el, er, [&](int i) { + return scc_id[eds[i][0]] == scc_id[eds[i][1]]; + }); + for (auto it = el; it != split; it++) joins[*it] = mid; if (tr - tl == 1) return; - rep(i, split, er) { - auto& [u, v] = eds[idx[i]]; + for (auto it = split; it != er; it++) { + auto& [u, v] = eds[*it]; u = scc_id[u], v = scc_id[v]; } self(self, el, split, tl, mid); @@ -45,6 +47,6 @@ vi offline_incremental_scc(vector> eds, }; // uses -1 as the lower bound to correctly handle // self-edges - divide_and_conquer(divide_and_conquer, 0, m, -1, m); + divide_and_conquer(divide_and_conquer, all(idx), -1, m); return joins; } diff --git a/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp b/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp index 5dc99538..a7e3a2b5 100644 --- a/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp +++ b/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp @@ -13,6 +13,7 @@ int main() { vector> eds(m); for (auto& [u, v] : eds) cin >> u >> v; auto joins = offline_incremental_scc(eds, n); + // assert joins[i] == -1 for self-edges for (int t = 0; t < m; t++) assert((eds[t][0] == eds[t][1]) == (joins[t] == -1)); vector order(m); diff --git a/tests/library_checker_aizu_tests/math/xor_basis_intersection.test.cpp b/tests/library_checker_aizu_tests/math/xor_basis_intersection.test.cpp index 44239449..8f88b24a 100644 --- a/tests/library_checker_aizu_tests/math/xor_basis_intersection.test.cpp +++ b/tests/library_checker_aizu_tests/math/xor_basis_intersection.test.cpp @@ -17,11 +17,10 @@ int main() { cin.tie(0)->sync_with_stdio(0); int t; cin >> t; - basis basis1, basis2; while (t--) { int n; cin >> n; - basis1.b.clear(); + basis basis1; for (int i = 0; i < n; i++) { int val; cin >> val; @@ -30,7 +29,7 @@ int main() { check_condition(basis1); int m; cin >> m; - basis2.b.clear(); + basis basis2; for (int j = 0; j < m; j++) { int val; cin >> val; From 02d3bdbba715b9345153d7b30b8e9007547ed305 Mon Sep 17 00:00:00 2001 From: GitHub Date: Fri, 13 Dec 2024 22:29:01 +0000 Subject: [PATCH 36/57] [auto-verifier] verify commit 55404815e76c1d81d1bb1594a9f53d53413c5d23 --- .verify-helper/timestamps.remote.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index 5ae064cd..128728d6 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -54,13 +54,13 @@ "tests/library_checker_aizu_tests/graphs/connected_components_of_complement_graph.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/graphs/dijkstra_aizu.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/graphs/dijkstra_lib_checker.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/graphs/directed_cycle.test.cpp": "2024-12-13 15:30:48 -0600", +"tests/library_checker_aizu_tests/graphs/directed_cycle.test.cpp": "2024-12-13 16:14:15 -0600", "tests/library_checker_aizu_tests/graphs/enumerate_triangles.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/graphs/hopcroft_karp_aizu.test.cpp": "2024-11-19 11:51:33 -0600", "tests/library_checker_aizu_tests/graphs/hopcroft_karp_lib_checker.test.cpp": "2024-11-19 11:51:33 -0600", "tests/library_checker_aizu_tests/graphs/mst.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp": "2024-12-13 15:30:48 -0600", -"tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp": "2024-12-13 15:30:48 -0600", +"tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp": "2024-12-13 16:14:15 -0600", +"tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp": "2024-12-13 16:14:15 -0600", "tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/handmade_tests/count_paths_forest.test.cpp": "2024-12-13 15:23:04 -0600", "tests/library_checker_aizu_tests/handmade_tests/dsu_size.test.cpp": "2024-11-17 14:04:03 -0600", From 93b4a5be1128aca45bf83f5043a50b7427ba3f39 Mon Sep 17 00:00:00 2001 From: GitHub Date: Sat, 14 Dec 2024 04:15:42 +0000 Subject: [PATCH 37/57] [auto-verifier] verify commit 0ed6e32e528d6bbcb1ff488e5125540839ebb8b6 --- .verify-helper/timestamps.remote.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index 128728d6..e48d3f69 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -54,13 +54,13 @@ "tests/library_checker_aizu_tests/graphs/connected_components_of_complement_graph.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/graphs/dijkstra_aizu.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/graphs/dijkstra_lib_checker.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/graphs/directed_cycle.test.cpp": "2024-12-13 16:14:15 -0600", +"tests/library_checker_aizu_tests/graphs/directed_cycle.test.cpp": "2024-12-13 16:16:45 -0600", "tests/library_checker_aizu_tests/graphs/enumerate_triangles.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/graphs/hopcroft_karp_aizu.test.cpp": "2024-11-19 11:51:33 -0600", "tests/library_checker_aizu_tests/graphs/hopcroft_karp_lib_checker.test.cpp": "2024-11-19 11:51:33 -0600", "tests/library_checker_aizu_tests/graphs/mst.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp": "2024-12-13 16:14:15 -0600", -"tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp": "2024-12-13 16:14:15 -0600", +"tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp": "2024-12-13 16:16:45 -0600", +"tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp": "2024-12-13 16:16:45 -0600", "tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/handmade_tests/count_paths_forest.test.cpp": "2024-12-13 15:23:04 -0600", "tests/library_checker_aizu_tests/handmade_tests/dsu_size.test.cpp": "2024-11-17 14:04:03 -0600", From b461c4051bb490b27d1700fbfc81fc775f026bf9 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sat, 14 Dec 2024 12:46:21 -0600 Subject: [PATCH 38/57] seeing if iterative scc is any faster --- .../offline_incremental_scc.hpp | 2 +- .../strongly_connected_components/scc.hpp | 51 +++++++++++-------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp index 6cec8bbd..34041c1c 100644 --- a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp +++ b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp @@ -32,7 +32,7 @@ vi offline_incremental_scc(vector> eds, if (*it <= mid) adj[u].push_back(v); } rep(i, 0, sz(adj)) ids[vs[i]] = -1; - scc_id = sccs(adj).scc_id; + scc_id = sccs(adj).second; auto split = partition(el, er, [&](int i) { return scc_id[eds[i][0]] == scc_id[eds[i][1]]; }); diff --git a/library/graphs/strongly_connected_components/scc.hpp b/library/graphs/strongly_connected_components/scc.hpp index 81bf8777..32bfefc0 100644 --- a/library/graphs/strongly_connected_components/scc.hpp +++ b/library/graphs/strongly_connected_components/scc.hpp @@ -7,25 +7,34 @@ //! for each edge u -> v: scc_id[u] >= scc_id[v] //! @time O(n + m) //! @space O(n) -struct sccs { - int num_sccs = 0; - vi scc_id; - sccs(const vector& adj): scc_id(sz(adj), -1) { - int n = sz(adj), timer = 1; - vi tin(n), st; - auto dfs = [&](auto&& self, int v) -> int { - int low = tin[v] = timer++, siz = sz(st); - st.push_back(v); - for (int u : adj[v]) - if (scc_id[u] < 0) - low = min(low, tin[u] ? tin[u] : self(self, u)); - if (tin[v] == low) { - rep(i, siz, sz(st)) scc_id[st[i]] = num_sccs; - st.resize(siz); - num_sccs++; +pair> sccs(const vector>& adj) { + int num_sccs = 0, n = ssize(adj), timer = 0; + vector scc_id(n, -1), tin(n), low(n), st, e(n), p(n, -1); + for (int i = 0; i < n; i++) + if (!tin[i]) { + int v = i; + while (v >= 0) { + if (e[v]) { + int u = adj[v][e[v] - 1]; + if (scc_id[u] == -1) low[v] = min(low[v], low[u]); + } else { + low[v] = tin[v] = ++timer; + st.push_back(v); + } + if (e[v] < ssize(adj[v])) { + int u = adj[v][e[v]++]; + if (!tin[u]) p[u] = v, v = u; + } else { + if (low[v] == tin[v]) { + while (scc_id[v] == -1) { + scc_id[st.back()] = num_sccs; + st.pop_back(); + } + num_sccs++; + } + v = p[v]; + } } - return low; - }; - rep(i, 0, n) if (!tin[i]) dfs(dfs, i); - } -}; + } + return {num_sccs, scc_id}; +} From 83a7e027ee40437908443c5c7a3a244f21e22f48 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sat, 14 Dec 2024 12:50:34 -0600 Subject: [PATCH 39/57] Revert "seeing if iterative scc is any faster" This reverts commit b461c4051bb490b27d1700fbfc81fc775f026bf9. --- .../offline_incremental_scc.hpp | 2 +- .../strongly_connected_components/scc.hpp | 51 ++++++++----------- 2 files changed, 22 insertions(+), 31 deletions(-) diff --git a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp index 34041c1c..6cec8bbd 100644 --- a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp +++ b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp @@ -32,7 +32,7 @@ vi offline_incremental_scc(vector> eds, if (*it <= mid) adj[u].push_back(v); } rep(i, 0, sz(adj)) ids[vs[i]] = -1; - scc_id = sccs(adj).second; + scc_id = sccs(adj).scc_id; auto split = partition(el, er, [&](int i) { return scc_id[eds[i][0]] == scc_id[eds[i][1]]; }); diff --git a/library/graphs/strongly_connected_components/scc.hpp b/library/graphs/strongly_connected_components/scc.hpp index 32bfefc0..81bf8777 100644 --- a/library/graphs/strongly_connected_components/scc.hpp +++ b/library/graphs/strongly_connected_components/scc.hpp @@ -7,34 +7,25 @@ //! for each edge u -> v: scc_id[u] >= scc_id[v] //! @time O(n + m) //! @space O(n) -pair> sccs(const vector>& adj) { - int num_sccs = 0, n = ssize(adj), timer = 0; - vector scc_id(n, -1), tin(n), low(n), st, e(n), p(n, -1); - for (int i = 0; i < n; i++) - if (!tin[i]) { - int v = i; - while (v >= 0) { - if (e[v]) { - int u = adj[v][e[v] - 1]; - if (scc_id[u] == -1) low[v] = min(low[v], low[u]); - } else { - low[v] = tin[v] = ++timer; - st.push_back(v); - } - if (e[v] < ssize(adj[v])) { - int u = adj[v][e[v]++]; - if (!tin[u]) p[u] = v, v = u; - } else { - if (low[v] == tin[v]) { - while (scc_id[v] == -1) { - scc_id[st.back()] = num_sccs; - st.pop_back(); - } - num_sccs++; - } - v = p[v]; - } +struct sccs { + int num_sccs = 0; + vi scc_id; + sccs(const vector& adj): scc_id(sz(adj), -1) { + int n = sz(adj), timer = 1; + vi tin(n), st; + auto dfs = [&](auto&& self, int v) -> int { + int low = tin[v] = timer++, siz = sz(st); + st.push_back(v); + for (int u : adj[v]) + if (scc_id[u] < 0) + low = min(low, tin[u] ? tin[u] : self(self, u)); + if (tin[v] == low) { + rep(i, siz, sz(st)) scc_id[st[i]] = num_sccs; + st.resize(siz); + num_sccs++; } - } - return {num_sccs, scc_id}; -} + return low; + }; + rep(i, 0, n) if (!tin[i]) dfs(dfs, i); + } +}; From 3fd132ae4764ec290a08f039762db862e6aaf008 Mon Sep 17 00:00:00 2001 From: GitHub Date: Sat, 14 Dec 2024 19:07:07 +0000 Subject: [PATCH 40/57] [auto-verifier] verify commit 83a7e027ee40437908443c5c7a3a244f21e22f48 --- .verify-helper/timestamps.remote.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index e48d3f69..f53ee4c4 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -54,13 +54,13 @@ "tests/library_checker_aizu_tests/graphs/connected_components_of_complement_graph.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/graphs/dijkstra_aizu.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/graphs/dijkstra_lib_checker.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/graphs/directed_cycle.test.cpp": "2024-12-13 16:16:45 -0600", +"tests/library_checker_aizu_tests/graphs/directed_cycle.test.cpp": "2024-12-14 12:50:34 -0600", "tests/library_checker_aizu_tests/graphs/enumerate_triangles.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/graphs/hopcroft_karp_aizu.test.cpp": "2024-11-19 11:51:33 -0600", "tests/library_checker_aizu_tests/graphs/hopcroft_karp_lib_checker.test.cpp": "2024-11-19 11:51:33 -0600", "tests/library_checker_aizu_tests/graphs/mst.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp": "2024-12-13 16:16:45 -0600", -"tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp": "2024-12-13 16:16:45 -0600", +"tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp": "2024-12-14 12:50:34 -0600", +"tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp": "2024-12-14 12:50:34 -0600", "tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/handmade_tests/count_paths_forest.test.cpp": "2024-12-13 15:23:04 -0600", "tests/library_checker_aizu_tests/handmade_tests/dsu_size.test.cpp": "2024-11-17 14:04:03 -0600", From 8218b942aa69563cd5e41d1601002e93dc30ef8d Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sat, 14 Dec 2024 13:29:53 -0600 Subject: [PATCH 41/57] trying this speedup --- .../strongly_connected_components/offline_incremental_scc.hpp | 2 +- library/graphs/strongly_connected_components/scc.hpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp index 6cec8bbd..6cb13da8 100644 --- a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp +++ b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp @@ -15,7 +15,7 @@ vi offline_incremental_scc(vector> eds, int m = sz(eds); vi ids(n, -1), joins(m, m), idx(m), vs(n), scc_id; iota(all(idx), 0); - vector adj; + vector> adj; auto divide_and_conquer = [&](auto&& self, auto el, auto er, int tl, int tr) { adj.clear(); diff --git a/library/graphs/strongly_connected_components/scc.hpp b/library/graphs/strongly_connected_components/scc.hpp index 81bf8777..4f73fe2f 100644 --- a/library/graphs/strongly_connected_components/scc.hpp +++ b/library/graphs/strongly_connected_components/scc.hpp @@ -7,10 +7,10 @@ //! for each edge u -> v: scc_id[u] >= scc_id[v] //! @time O(n + m) //! @space O(n) -struct sccs { +template struct sccs { int num_sccs = 0; vi scc_id; - sccs(const vector& adj): scc_id(sz(adj), -1) { + sccs(const G& adj) : scc_id(sz(adj), -1) { int n = sz(adj), timer = 1; vi tin(n), st; auto dfs = [&](auto&& self, int v) -> int { From 6c08aded34a8d0e9cb9cbc91acd3a180000a057e Mon Sep 17 00:00:00 2001 From: GitHub Date: Sat, 14 Dec 2024 19:44:34 +0000 Subject: [PATCH 42/57] [auto-verifier] verify commit 8218b942aa69563cd5e41d1601002e93dc30ef8d --- .verify-helper/timestamps.remote.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index f53ee4c4..fef2c927 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -54,13 +54,14 @@ "tests/library_checker_aizu_tests/graphs/connected_components_of_complement_graph.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/graphs/dijkstra_aizu.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/graphs/dijkstra_lib_checker.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/graphs/directed_cycle.test.cpp": "2024-12-14 12:50:34 -0600", +"tests/library_checker_aizu_tests/graphs/directed_cycle.test.cpp": "2024-12-14 13:29:53 -0600", "tests/library_checker_aizu_tests/graphs/enumerate_triangles.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/graphs/hopcroft_karp_aizu.test.cpp": "2024-11-19 11:51:33 -0600", "tests/library_checker_aizu_tests/graphs/hopcroft_karp_lib_checker.test.cpp": "2024-11-19 11:51:33 -0600", "tests/library_checker_aizu_tests/graphs/mst.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp": "2024-12-14 12:50:34 -0600", -"tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp": "2024-12-14 12:50:34 -0600", +"tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp": "2024-12-14 13:29:53 -0600", +"tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp": "2024-12-14 13:29:53 -0600", +"tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp": "2024-12-14 13:29:53 -0600", "tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/handmade_tests/count_paths_forest.test.cpp": "2024-12-13 15:23:04 -0600", "tests/library_checker_aizu_tests/handmade_tests/dsu_size.test.cpp": "2024-11-17 14:04:03 -0600", From dc488070aede0d713ef2bae7005432e156df3abc Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 15 Dec 2024 09:27:55 -0600 Subject: [PATCH 43/57] fix format --- .verify-helper/timestamps.remote.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index c5ffa0b4..29b74d9c 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -62,5 +62,5 @@ "tests/library_checker_aizu_tests/math/totient.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/strings/lcs_dp.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/strings/lcs_queries.test.cpp": "2024-12-14 19:50:29 -0600", -"tests/library_checker_aizu_tests/strings/lcs_queries_merge_sort_tree.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/strings/lcs_queries_merge_sort_tree.test.cpp": "2024-12-05 10:41:42 -0600" } \ No newline at end of file From 359e1a9d4b460a511d096edbf1a80a07481eced3 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 15 Dec 2024 09:29:23 -0600 Subject: [PATCH 44/57] revert --- .../seg_tree_uncommon/implicit.hpp | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/library/data_structures/seg_tree_uncommon/implicit.hpp b/library/data_structures/seg_tree_uncommon/implicit.hpp index 5e7ef13b..76a6570b 100644 --- a/library/data_structures/seg_tree_uncommon/implicit.hpp +++ b/library/data_structures/seg_tree_uncommon/implicit.hpp @@ -2,23 +2,23 @@ //! @code //! implicit_seg_tree<10'000'000> ist(l, r); //! @endcode -template struct implicit_seg_tree { - using dt = array; //!< min, number of mins +template struct implicit_seg_tree { + using dt = array; //!< min, number of mins static dt op(const dt& l, const dt& r) { if (l[0] == r[0]) return {l[0], l[1] + r[1]}; return min(l, r); } - static constexpr dt unit{INT_MAX, 0}; + static constexpr dt unit{LLONG_MAX, 0LL}; struct node { dt num; - int lazy = 0; + ll lazy = 0; int lch = -1, rch = -1; } tree[N]; int ptr = 0, root_l, root_r; - implicit_seg_tree(int l, int r) : root_l(l), root_r(r) { + implicit_seg_tree(int l, int r): root_l(l), root_r(r) { tree[ptr++].num = {0, r - l}; } - void apply(int add, int v) { + void apply(ll add, int v) { tree[v].num[0] += add; tree[v].lazy += add; } @@ -35,11 +35,11 @@ template struct implicit_seg_tree { tree[v].lazy = 0; } } - void update(int l, int r, int add) { // [l, r) + void update(int l, int r, ll add) { // [l, r) update(l, r, add, root_l, root_r, 0); } - void update(int l, int r, int add, int tl, int tr, - int v) { + void update(int l, int r, ll add, int tl, int tr, + int v) { if (r <= tl || tr <= l) return; if (l <= tl && tr <= r) return apply(add, v); int tm = tl + (tr - tl) / 2; @@ -47,9 +47,9 @@ template struct implicit_seg_tree { update(l, r, add, tl, tm, tree[v].lch); update(l, r, add, tm, tr, tree[v].rch); tree[v].num = - op(tree[tree[v].lch].num, tree[tree[v].rch].num); + op(tree[tree[v].lch].num, tree[tree[v].rch].num); } - dt query(int l, int r) { // [l, r) + dt query(int l, int r) { // [l, r) return query(l, r, root_l, root_r, 0); } dt query(int l, int r, int tl, int tr, int v) { @@ -58,6 +58,6 @@ template struct implicit_seg_tree { int tm = tl + (tr - tl) / 2; push(tl, tm, tr, v); return op(query(l, r, tl, tm, tree[v].lch), - query(l, r, tm, tr, tree[v].rch)); + query(l, r, tm, tr, tree[v].rch)); } }; From 6c4a76f745aa562024978eed4ad3afeb8b2f986a Mon Sep 17 00:00:00 2001 From: GitHub Date: Sun, 15 Dec 2024 16:29:58 +0000 Subject: [PATCH 45/57] [auto-verifier] verify commit 359e1a9d4b460a511d096edbf1a80a07481eced3 --- .verify-helper/timestamps.remote.json | 72 ++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index 29b74d9c..3e89fa2b 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -20,6 +20,8 @@ "tests/library_checker_aizu_tests/data_structures/distinct_query.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/data_structures/dsu_bipartite.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/data_structures/dsu_restorable.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/data_structures/dsu_segtree_undo_trick.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/data_structures/implicit_seg_tree.test.cpp": "2024-12-15 09:29:23 -0600", "tests/library_checker_aizu_tests/data_structures/kruskal_tree_aizu.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/data_structures/kth_smallest_pst.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/data_structures/kth_smallest_wavelet_matrix.test.cpp": "2024-11-19 08:31:51 -0600", @@ -36,9 +38,48 @@ "tests/library_checker_aizu_tests/data_structures/persistent_seg_tree.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/data_structures/pq_ds_undo_sliding_window.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/data_structures/pq_ds_undo_with_dsu.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/data_structures/range_parallel_dsu.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/data_structures/rmq_disjoint_sparse_table.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/data_structures/rmq_sparse_table.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/data_structures/rmq_sparse_table_inc.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/data_structures/simple_tree.test.cpp": "2024-12-14 15:47:13 -0600", +"tests/library_checker_aizu_tests/data_structures/simple_tree_inc.test.cpp": "2024-12-14 15:47:13 -0600", +"tests/library_checker_aizu_tests/data_structures/simple_tree_inc_line.test.cpp": "2024-12-14 15:47:13 -0600", +"tests/library_checker_aizu_tests/data_structures/simple_tree_line.test.cpp": "2024-12-14 15:47:13 -0600", "tests/library_checker_aizu_tests/flow/dinic_aizu.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/flow/hungarian.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/flow/min_cost_max_flow.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/graphs/biconnected_components.test.cpp": "2024-12-15 09:01:54 -0600", +"tests/library_checker_aizu_tests/graphs/connected_components_of_complement_graph.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/graphs/dijkstra_aizu.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/graphs/dijkstra_lib_checker.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/graphs/directed_cycle.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/graphs/enumerate_triangles.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/graphs/hopcroft_karp_aizu.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/graphs/hopcroft_karp_lib_checker.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/graphs/mst.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp": "2024-12-15 09:01:54 -0600", +"tests/library_checker_aizu_tests/handmade_tests/count_paths_forest.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/handmade_tests/dsu_size.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/handmade_tests/dynamic_bitset.test.cpp": "2024-11-22 10:47:44 -0600", +"tests/library_checker_aizu_tests/handmade_tests/edge_cd_small_trees.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/handmade_tests/fib_matrix_expo.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/handmade_tests/lca_ladder_forest.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/handmade_tests/manacher.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/handmade_tests/merge_st_and_wavelet.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/handmade_tests/mobius.test.cpp": "2024-12-10 12:31:07 -0600", +"tests/library_checker_aizu_tests/handmade_tests/mod_int.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/handmade_tests/n_choose_k.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/handmade_tests/permutation_tree_small.test.cpp": "2024-12-14 15:47:13 -0600", +"tests/library_checker_aizu_tests/handmade_tests/rmq_small_n.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/handmade_tests/sa_find_subarray.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/handmade_tests/seg_tree_find.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/handmade_tests/seg_tree_find_small.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/loops/chooses.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/loops/quotients.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/loops/submasks.test.cpp": "2024-11-17 14:04:03 -0600", @@ -60,7 +101,36 @@ "tests/library_checker_aizu_tests/math/solve_linear_mod.test.cpp": "2024-12-14 15:47:13 -0600", "tests/library_checker_aizu_tests/math/tetration.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/totient.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_binary_tree.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_k_ary_tree.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/count_rectangles.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/max_rect_histogram.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/strings/kmp.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/strings/lcp_array.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/strings/lcp_query_palindrome.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/strings/lcp_query_zfunc.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/strings/lcs_dp.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/strings/lcs_queries.test.cpp": "2024-12-14 19:50:29 -0600", -"tests/library_checker_aizu_tests/strings/lcs_queries_merge_sort_tree.test.cpp": "2024-12-05 10:41:42 -0600" +"tests/library_checker_aizu_tests/strings/lcs_queries_merge_sort_tree.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/strings/manacher.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/strings/multi_matching_bs.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/strings/prefix_function.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/strings/sa_cmp.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/strings/sa_sort_pairs.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/strings/single_matching_bs.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/strings/suffix_array.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/strings/suffix_array_short.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/strings/trie.test.cpp": "2024-12-05 10:41:42 -0600", +"tests/library_checker_aizu_tests/strings/wildcard_pattern_matching.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/trees/count_paths_per_length.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/trees/edge_cd_contour_range_query.test.cpp": "2024-12-14 18:43:21 -0600", +"tests/library_checker_aizu_tests/trees/edge_cd_contour_range_update.test.cpp": "2024-12-14 18:43:21 -0600", +"tests/library_checker_aizu_tests/trees/edge_cd_count_paths_per_length.test.cpp": "2024-12-14 18:43:21 -0600", +"tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp": "2024-12-14 18:43:21 -0600", +"tests/library_checker_aizu_tests/trees/kth_path_ladder.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/trees/kth_path_linear.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/trees/kth_path_tree_lift.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/trees/lca_all_methods_aizu.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/trees/lca_all_methods_lib_checker.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/trees/subtree_isomorphism.test.cpp": "2024-12-15 09:26:21 -0600" } \ No newline at end of file From cc684ec2ab27040fe119d8e2c93b06b4a642db15 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 15 Dec 2024 12:37:34 -0600 Subject: [PATCH 46/57] format --- .../offline_incremental_scc.hpp | 4 +- .../math/count_paths/count_paths_triangle.hpp | 9 +-- .../count_paths_per_length.hpp | 58 ++++++++++--------- library/trees/subtree_isomorphism.hpp | 4 +- .../library_checker_aizu_tests/cd_asserts.hpp | 42 +++++++------- .../range_parallel_dsu.test.cpp | 3 +- .../data_structures/rmq_linear.test.cpp | 14 +++-- .../graphs/offline_incremental_scc.test.cpp | 3 +- .../count_paths_forest.test.cpp | 8 +-- .../edge_cd_small_trees.test.cpp | 14 ++--- .../handmade_tests/functional_graph.test.cpp | 48 +++++++-------- .../mono_st_asserts.hpp | 10 ++-- .../trees/kth_path_tree_lift.test.cpp | 10 ++-- .../trees/subtree_isomorphism.test.cpp | 6 +- 14 files changed, 124 insertions(+), 109 deletions(-) diff --git a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp index cabd60d0..510791bd 100644 --- a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp +++ b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp @@ -11,13 +11,13 @@ //! @time O((n + m) log m) //! @space O(n + m) vi offline_incremental_scc(vector> eds, - int n) { + int n) { int m = sz(eds); vi ids(n, -1), joins(m, m), idx(m), vs(n), scc_id; iota(all(idx), 0); vector> adj; auto divide_and_conquer = [&](auto&& self, auto el, - auto er, int tl, int tr) { + auto er, int tl, int tr) { adj.clear(); int mid = midpoint(tl, tr); for (auto it = el; it != er; it++) { diff --git a/library/math/count_paths/count_paths_triangle.hpp b/library/math/count_paths/count_paths_triangle.hpp index 0a207d3c..a9c59c56 100644 --- a/library/math/count_paths/count_paths_triangle.hpp +++ b/library/math/count_paths/count_paths_triangle.hpp @@ -6,7 +6,8 @@ vl divide_and_conquer(vl h, vl bottom) { { int start = - ranges::find_if(h, [](ll x) { return x; }) - begin(h); + ranges::find_if(h, [](ll x) { return x; }) - + begin(h); h.erase(begin(h), begin(h) + start); bottom.erase(begin(bottom), begin(bottom) + start); } @@ -15,10 +16,10 @@ vl divide_and_conquer(vl h, vl bottom) { if (n == 1) return vl(h[0], bottom[0]); int mid = n / 2; auto rect_left = - divide_and_conquer(vl(begin(h), begin(h) + mid), - vl(begin(bottom), begin(bottom) + mid)); + divide_and_conquer(vl(begin(h), begin(h) + mid), + vl(begin(bottom), begin(bottom) + mid)); auto [rect_right, rect_top] = - get_right_and_top(rect_left, vl(mid + all(bottom))); + get_right_and_top(rect_left, vl(mid + all(bottom))); vl h_right(mid + all(h)); for (ll& hh : h_right) hh -= h[mid - 1]; auto upper_right = divide_and_conquer(h_right, rect_top); diff --git a/library/trees/centroid_decomp_uncommon/count_paths_per_length.hpp b/library/trees/centroid_decomp_uncommon/count_paths_per_length.hpp index 8e59e156..dc3e4256 100644 --- a/library/trees/centroid_decomp_uncommon/count_paths_per_length.hpp +++ b/library/trees/centroid_decomp_uncommon/count_paths_per_length.hpp @@ -10,33 +10,35 @@ vector count_paths_per_length(const vector& adj) { vector num_paths(sz(adj)); centroid(adj, - [&](const vector& cd_adj, int cent, int) { - vector> child_depths; - for (int v : cd_adj[cent]) { - child_depths.emplace_back(1, 0.0); - for (queue q({{v, cent}}); !empty(q);) { - child_depths.back().push_back(sz(q)); - queue new_q; - while (!empty(q)) { - auto [u, p] = q.front(); - q.pop(); - for (int w : cd_adj[u]) { - if (w == p) continue; - new_q.emplace(w, u); - } - } - swap(q, new_q); - } - } - ranges::sort(child_depths, {}, [&](auto& x) { return sz(x); }); - vector total_depth(1, 1.0); - for (auto& cnt_depth : child_depths) { - auto prod = conv(total_depth, cnt_depth); - rep(i, 1, sz(prod)) num_paths[i] += llround(prod[i]); - total_depth.resize(sz(cnt_depth)); - rep(i, 1, sz(cnt_depth)) total_depth[i] += - cnt_depth[i]; - } - }); + [&](const vector& cd_adj, int cent, int) { + vector> child_depths; + for (int v : cd_adj[cent]) { + child_depths.emplace_back(1, 0.0); + for (queue q({{v, cent}}); !empty(q);) { + child_depths.back().push_back(sz(q)); + queue new_q; + while (!empty(q)) { + auto [u, p] = q.front(); + q.pop(); + for (int w : cd_adj[u]) { + if (w == p) continue; + new_q.emplace(w, u); + } + } + swap(q, new_q); + } + } + ranges::sort(child_depths, {}, + [&](auto& x) { return sz(x); }); + vector total_depth(1, 1.0); + for (auto& cnt_depth : child_depths) { + auto prod = conv(total_depth, cnt_depth); + rep(i, 1, sz(prod)) num_paths[i] += + llround(prod[i]); + total_depth.resize(sz(cnt_depth)); + rep(i, 1, sz(cnt_depth)) total_depth[i] += + cnt_depth[i]; + } + }); return num_paths; } diff --git a/library/trees/subtree_isomorphism.hpp b/library/trees/subtree_isomorphism.hpp index 50cd510c..c50f1e0d 100644 --- a/library/trees/subtree_isomorphism.hpp +++ b/library/trees/subtree_isomorphism.hpp @@ -22,7 +22,9 @@ auto subtree_iso(const auto& adj) { for (int u : adj[v]) if (u != p) ch_ids.push_back(self(self, u, v)); ranges::sort(ch_ids); - return iso_id[v] = hashes.try_emplace(ch_ids, sz(hashes)).first->second; + return iso_id[v] = + hashes.try_emplace(ch_ids, sz(hashes)) + .first->second; }; rep(i, 0, sz(adj)) if (iso_id[i] == -1) dfs(dfs, i, i); return pair{sz(hashes), iso_id}; diff --git a/tests/library_checker_aizu_tests/cd_asserts.hpp b/tests/library_checker_aizu_tests/cd_asserts.hpp index 596f1b8b..8dcb6820 100644 --- a/tests/library_checker_aizu_tests/cd_asserts.hpp +++ b/tests/library_checker_aizu_tests/cd_asserts.hpp @@ -4,26 +4,26 @@ void cd_asserts(const vector>& adj) { vector decomp_size(sz(adj), -1); vector naive_par_decomp(sz(adj), -1); centroid(adj, - [&](const vector>& cd_adj, int cent, - int par_cent) -> void { - assert(naive_par_decomp[cent] == par_cent); - assert(decomp_size[cent] == -1); - auto dfs = [&](auto&& self, int u, int p) -> int { - naive_par_decomp[u] = cent; - int sub_size = 1; - for (int v : cd_adj[u]) - if (v != p) sub_size += self(self, v, u); - return sub_size; - }; - decomp_size[cent] = dfs(dfs, cent, -1); - if (par_cent != -1) - assert(1 <= decomp_size[cent] && - 2 * decomp_size[cent] <= decomp_size[par_cent]); - for (int u : cd_adj[cent]) { - int sz_subtree = dfs(dfs, u, cent); - assert(1 <= sz_subtree && - 2 * sz_subtree <= decomp_size[cent]); - } - }); + [&](const vector>& cd_adj, int cent, + int par_cent) -> void { + assert(naive_par_decomp[cent] == par_cent); + assert(decomp_size[cent] == -1); + auto dfs = [&](auto&& self, int u, int p) -> int { + naive_par_decomp[u] = cent; + int sub_size = 1; + for (int v : cd_adj[u]) + if (v != p) sub_size += self(self, v, u); + return sub_size; + }; + decomp_size[cent] = dfs(dfs, cent, -1); + if (par_cent != -1) + assert(1 <= decomp_size[cent] && + 2 * decomp_size[cent] <= decomp_size[par_cent]); + for (int u : cd_adj[cent]) { + int sz_subtree = dfs(dfs, u, cent); + assert(1 <= sz_subtree && + 2 * sz_subtree <= decomp_size[cent]); + } + }); rep(i, 0, sz(adj)) assert(decomp_size[i] >= 1); } diff --git a/tests/library_checker_aizu_tests/data_structures/range_parallel_dsu.test.cpp b/tests/library_checker_aizu_tests/data_structures/range_parallel_dsu.test.cpp index 3d01d17f..d9e05292 100644 --- a/tests/library_checker_aizu_tests/data_structures/range_parallel_dsu.test.cpp +++ b/tests/library_checker_aizu_tests/data_structures/range_parallel_dsu.test.cpp @@ -30,7 +30,8 @@ int main() { dsu.join(a, b, k, f); queries.push_back({a, b, k}); cout << ans.x << '\n'; - if (qq == 0 || qq == 1 || qq == 10 || qq == 1000 || qq == 100'000 || qq == q - 1) { + if (qq == 0 || qq == 1 || qq == 10 || qq == 1000 || + qq == 100'000 || qq == q - 1) { auto uf = get_rp_dsu(queries, n); vector sums(n); mint offline_ans = 0; diff --git a/tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp b/tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp index 1d9dba12..90a06dcf 100644 --- a/tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp +++ b/tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp @@ -17,14 +17,20 @@ int main() { int l, r; cin >> l >> r; int idx_right_min = rmq_less.query_idx(l, r - 1); - assert(idx_right_min + 1 == r || rmq_less.query(idx_right_min + 1, r - 1) > a[idx_right_min]); + assert(idx_right_min + 1 == r || + rmq_less.query(idx_right_min + 1, r - 1) > + a[idx_right_min]); assert(l <= idx_right_min && idx_right_min < r); assert(rmq_less.query(l, r - 1) == a[idx_right_min]); - assert(idx_right_min == rmq_greater.query_idx(l, r - 1)); + assert( + idx_right_min == rmq_greater.query_idx(l, r - 1)); int idx_left_min = rmq_less_equal.query_idx(l, r - 1); - assert(l == idx_left_min || rmq_less_equal.query(l, idx_left_min - 1) > a[idx_left_min]); + assert(l == idx_left_min || + rmq_less_equal.query(l, idx_left_min - 1) > + a[idx_left_min]); assert(l <= idx_left_min && idx_left_min < r); - assert(idx_left_min == rmq_greater_equal.query_idx(l, r - 1)); + assert(idx_left_min == + rmq_greater_equal.query_idx(l, r - 1)); assert(a[idx_right_min] == a[idx_left_min]); assert(idx_left_min <= idx_right_min); cout << a[idx_right_min] << '\n'; diff --git a/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp b/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp index a7e3a2b5..18a6f6aa 100644 --- a/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp +++ b/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp @@ -18,7 +18,8 @@ int main() { assert((eds[t][0] == eds[t][1]) == (joins[t] == -1)); vector order(m); iota(all(order), 0); - ranges::sort(all(order), {}, [&](int i) { return joins[i]; }); + ranges::sort(all(order), {}, + [&](int i) { return joins[i]; }); UF uf(n); mint sum = 0; for (int t = 0, it = 0; t < m; t++) { diff --git a/tests/library_checker_aizu_tests/handmade_tests/count_paths_forest.test.cpp b/tests/library_checker_aizu_tests/handmade_tests/count_paths_forest.test.cpp index d80d07c4..b099d875 100644 --- a/tests/library_checker_aizu_tests/handmade_tests/count_paths_forest.test.cpp +++ b/tests/library_checker_aizu_tests/handmade_tests/count_paths_forest.test.cpp @@ -8,7 +8,7 @@ #include "../../../library/trees/centroid_decomp_uncommon/count_paths_per_length.hpp" #include "../cd_asserts.hpp" vector> naive(const vector>& adj, - dsu_restorable& dsu) { + dsu_restorable& dsu) { tree_lift tl(adj); int n = sz(adj); vector> cnts_naive(n + 1, vector(n, 0)); @@ -42,13 +42,13 @@ int main() { vector> cnts_naive = naive(adj, dsu); for (int k = 1; k <= n; k++) assert( - count_paths_per_node(adj, k) == cnts_naive[k]); + count_paths_per_node(adj, k) == cnts_naive[k]); vector num_paths_len = count_paths_per_length(adj); for (int k = 1; k < n; k++) { vector count_paths = - count_paths_per_node(adj, k); + count_paths_per_node(adj, k); ll total_paths = accumulate(begin(count_paths), - end(count_paths), 0LL); + end(count_paths), 0LL); assert(total_paths % (k + 1) == 0); total_paths /= k + 1; assert(num_paths_len[k] == total_paths); diff --git a/tests/library_checker_aizu_tests/handmade_tests/edge_cd_small_trees.test.cpp b/tests/library_checker_aizu_tests/handmade_tests/edge_cd_small_trees.test.cpp index d677546c..df92f5e3 100644 --- a/tests/library_checker_aizu_tests/handmade_tests/edge_cd_small_trees.test.cpp +++ b/tests/library_checker_aizu_tests/handmade_tests/edge_cd_small_trees.test.cpp @@ -9,21 +9,21 @@ int main() { { vector> adj; edge_cd(adj, - [&](const vector>&, int, int) -> void { - assert(false); - }); + [&](const vector>&, int, int) -> void { + assert(false); + }); } { vector> adj(1); edge_cd(adj, - [&](const vector>&, int, int) -> void { - assert(false); - }); + [&](const vector>&, int, int) -> void { + assert(false); + }); } for (int n = 2; n <= 7; n++) { int num_codes = mpow(n, n - 2).x; vector> pruf_codes(num_codes, - vector(n - 2)); + vector(n - 2)); for (int i = 0; i < num_codes; i++) { int val = i; for (int j = 0; j < n - 2; j++) { diff --git a/tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp b/tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp index 12de5244..8bb0531a 100644 --- a/tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp +++ b/tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp @@ -9,7 +9,7 @@ struct functional_graph_processor { init(sz(next)); build(next); } - template + template functional_graph_processor(const Graph_t &g) { init(g.n); build(g); @@ -101,23 +101,23 @@ struct functional_graph_processor { } int n; vector> cycle; - vector cycle_id; // id of the cycle it belongs to, - // -1 if not part of one - vector cycle_pos; // position in its cycle, -1 if - // not part of one - vector cycle_prev; // previous vertex in its cycle, - // -1 if not part of one - vector component_size; // size of its weakly - // connected component - vector root_of; // first reachable node in a cycle - vector depth; // distance to its root + vector cycle_id; // id of the cycle it belongs to, + // -1 if not part of one + vector cycle_pos; // position in its cycle, -1 if + // not part of one + vector cycle_prev; // previous vertex in its cycle, + // -1 if not part of one + vector component_size; // size of its weakly + // connected component + vector root_of; // first reachable node in a cycle + vector depth; // distance to its root vector> - abr; // forest of arborescences of reversed edges not - // on the cycles - vector order; // dfs order of abr - vector pos; // pos in the dfs order - vector end; // [pos[u], end[u]) denotes the subtree - vector size; // size of the subtree in abr + abr; // forest of arborescences of reversed edges not + // on the cycles + vector order; // dfs order of abr + vector pos; // pos in the dfs order + vector end; // [pos[u], end[u]) denotes the subtree + vector size; // size of the subtree in abr }; int main() { cin.tie(0)->sync_with_stdio(0); @@ -130,7 +130,7 @@ int main() { assert(cycle == fgp.cycle); for (int i = 0; i < n; i++) { int root = - cycle[t[i].root_of.first][t[i].root_of.second]; + cycle[t[i].root_of.first][t[i].root_of.second]; assert(root == fgp.root_of[i]); assert(t[i].childs == fgp.abr[i]); assert((root == i) == (fgp.cycle_id[i] != -1)); @@ -139,13 +139,13 @@ int main() { assert(t[i].root_of.second == fgp.cycle_pos[i]); int cyc_len = ssize(cycle[t[i].root_of.first]); assert( - cycle[t[i].root_of.first] - [(t[i].root_of.second + 1) % cyc_len] == - a[i]); + cycle[t[i].root_of.first] + [(t[i].root_of.second + 1) % cyc_len] == + a[i]); assert(fgp.cycle_prev[i] == - cycle[t[i].root_of.first] - [(t[i].root_of.second - 1 + cyc_len) % - cyc_len]); + cycle[t[i].root_of.first] + [(t[i].root_of.second - 1 + cyc_len) % + cyc_len]); } else { assert(fgp.cycle_prev[i] == -1); } diff --git a/tests/library_checker_aizu_tests/mono_st_asserts.hpp b/tests/library_checker_aizu_tests/mono_st_asserts.hpp index 70f1b818..06ee62a6 100644 --- a/tests/library_checker_aizu_tests/mono_st_asserts.hpp +++ b/tests/library_checker_aizu_tests/mono_st_asserts.hpp @@ -5,7 +5,7 @@ #include "../../library/data_structures/uncommon/linear_rmq.hpp" tuple>, vector> min_cartesian_tree(const vector& a, - const vector& l, const vector& r) { + const vector& l, const vector& r) { int n = sz(a); assert(sz(l) == n && sz(r) == n); auto is_node = [&](int i) -> bool { @@ -23,7 +23,7 @@ min_cartesian_tree(const vector& a, root = i; } else if (is_node(i)) { bool le_par = - (l[i] >= 0 && (r[i] == n || a[l[i]] > a[r[i]])); + (l[i] >= 0 && (r[i] == n || a[l[i]] > a[r[i]])); adj[to_min[le_par ? l[i] : r[i]]].push_back(i); } } @@ -41,11 +41,11 @@ void mono_st_asserts(const vector& a) { p = cart_binary_tree(l); { vector old_way_ri = mono_st(vi{rbegin(a), rend(a)}, - [&](int x, int y) { return !cmp(y, x); }); + [&](int x, int y) { return !cmp(y, x); }); reverse(begin(old_way_ri), end(old_way_ri)); transform(begin(old_way_ri), end(old_way_ri), - begin(old_way_ri), - [&](int i) { return sz(a) - i - 1; }); + begin(old_way_ri), + [&](int i) { return sz(a) - i - 1; }); assert(r == old_way_ri); } int iterations = 0; diff --git a/tests/library_checker_aizu_tests/trees/kth_path_tree_lift.test.cpp b/tests/library_checker_aizu_tests/trees/kth_path_tree_lift.test.cpp index 9a656f62..376782a2 100644 --- a/tests/library_checker_aizu_tests/trees/kth_path_tree_lift.test.cpp +++ b/tests/library_checker_aizu_tests/trees/kth_path_tree_lift.test.cpp @@ -26,12 +26,14 @@ int main() { { int w = rnd(0, n - 1); assert(lc.on_path(u, v, w) == - (lc.dist_edges(u, w) + lc.dist_edges(w, v) == - lc.dist_edges(u, v))); + (lc.dist_edges(u, w) + lc.dist_edges(w, v) == + lc.dist_edges(u, v))); } if (u != v) { - assert(tl.kth_path(u, v, 1) == lc.next_on_path(u, v)); - assert(tl.kth_path(u, v, dist_in_edges - 1) == lc.next_on_path(v, u)); + assert( + tl.kth_path(u, v, 1) == lc.next_on_path(u, v)); + assert(tl.kth_path(u, v, dist_in_edges - 1) == + lc.next_on_path(v, u)); } } } diff --git a/tests/library_checker_aizu_tests/trees/subtree_isomorphism.test.cpp b/tests/library_checker_aizu_tests/trees/subtree_isomorphism.test.cpp index d9dbcb82..26babb98 100644 --- a/tests/library_checker_aizu_tests/trees/subtree_isomorphism.test.cpp +++ b/tests/library_checker_aizu_tests/trees/subtree_isomorphism.test.cpp @@ -20,11 +20,11 @@ int main() { adj_rooted[p].push_back(i); } auto [num_distinct_subtrees, iso_id] = - subtree_iso(adj_unrooted); + subtree_iso(adj_unrooted); auto [num_distinct_subtrees_rooted, iso_id_rooted] = - subtree_iso(adj_rooted); + subtree_iso(adj_rooted); assert( - num_distinct_subtrees == num_distinct_subtrees_rooted); + num_distinct_subtrees == num_distinct_subtrees_rooted); cout << num_distinct_subtrees << '\n'; for (int i = 0; i < n; i++) { cout << iso_id[i] << " "; From 941fa155c67d94e760186358cd38de22267d46fe Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 15 Dec 2024 12:40:15 -0600 Subject: [PATCH 47/57] rename folder --- .../add_edges_strongly_connected.hpp | 0 .../offline_incremental_scc.hpp | 0 library/graphs/{strongly_connected_components => scc}/scc.hpp | 0 .../graphs/offline_incremental_scc.test.cpp | 2 +- .../graphs/strongly_connected_components_aizu.test.cpp | 2 +- .../graphs/strongly_connected_components_lib_checker.test.cpp | 2 +- tests/library_checker_aizu_tests/scc_asserts.hpp | 4 ++-- 7 files changed, 5 insertions(+), 5 deletions(-) rename library/graphs/{strongly_connected_components => scc}/add_edges_strongly_connected.hpp (100%) rename library/graphs/{strongly_connected_components => scc}/offline_incremental_scc.hpp (100%) rename library/graphs/{strongly_connected_components => scc}/scc.hpp (100%) diff --git a/library/graphs/strongly_connected_components/add_edges_strongly_connected.hpp b/library/graphs/scc/add_edges_strongly_connected.hpp similarity index 100% rename from library/graphs/strongly_connected_components/add_edges_strongly_connected.hpp rename to library/graphs/scc/add_edges_strongly_connected.hpp diff --git a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp b/library/graphs/scc/offline_incremental_scc.hpp similarity index 100% rename from library/graphs/strongly_connected_components/offline_incremental_scc.hpp rename to library/graphs/scc/offline_incremental_scc.hpp diff --git a/library/graphs/strongly_connected_components/scc.hpp b/library/graphs/scc/scc.hpp similarity index 100% rename from library/graphs/strongly_connected_components/scc.hpp rename to library/graphs/scc/scc.hpp diff --git a/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp b/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp index 18a6f6aa..603c7edd 100644 --- a/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp +++ b/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp @@ -2,7 +2,7 @@ "https://judge.yosupo.jp/problem/incremental_scc" #include "../template.hpp" #include "../../../kactl/content/data-structures/UnionFind.h" -#include "../../../library/graphs/strongly_connected_components/offline_incremental_scc.hpp" +#include "../../../library/graphs/scc/offline_incremental_scc.hpp" #include "../../../library/math/mod_int.hpp" int main() { cin.tie(0)->sync_with_stdio(0); diff --git a/tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp b/tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp index 5c397092..e9e42a8d 100644 --- a/tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp +++ b/tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp @@ -2,7 +2,7 @@ "https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_C" #include "../template.hpp" #include "../scc_asserts.hpp" -#include "../../../library/graphs/strongly_connected_components/add_edges_strongly_connected.hpp" +#include "../../../library/graphs/scc/add_edges_strongly_connected.hpp" int main() { cin.tie(0)->sync_with_stdio(0); int n, m; diff --git a/tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp b/tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp index 82d6e0c2..08d7e4fa 100644 --- a/tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp +++ b/tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp @@ -1,7 +1,7 @@ #define PROBLEM "https://judge.yosupo.jp/problem/scc" #include "../template.hpp" #include "../scc_asserts.hpp" -#include "../../../library/graphs/strongly_connected_components/add_edges_strongly_connected.hpp" +#include "../../../library/graphs/scc/add_edges_strongly_connected.hpp" int main() { cin.tie(0)->sync_with_stdio(0); int n, m; diff --git a/tests/library_checker_aizu_tests/scc_asserts.hpp b/tests/library_checker_aizu_tests/scc_asserts.hpp index 48edbaae..b436c02a 100644 --- a/tests/library_checker_aizu_tests/scc_asserts.hpp +++ b/tests/library_checker_aizu_tests/scc_asserts.hpp @@ -1,7 +1,7 @@ #pragma once #include "../../library/contest/random.hpp" -#include "../../library/graphs/strongly_connected_components/add_edges_strongly_connected.hpp" -#include "../../library/graphs/strongly_connected_components/offline_incremental_scc.hpp" +#include "../../library/graphs/scc/add_edges_strongly_connected.hpp" +#include "../../library/graphs/scc/offline_incremental_scc.hpp" void scc_asserts(const vector>& adj) { int n = sz(adj); auto [num_sccs, scc_id] = sccs(adj); From 080f66ae4f287a8f82fb029e73c3a11b40b72071 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 15 Dec 2024 12:48:47 -0600 Subject: [PATCH 48/57] fail on path not found here --- tests/scripts/ptc.sh | 50 +++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/tests/scripts/ptc.sh b/tests/scripts/ptc.sh index d3684eb7..e9dbde79 100755 --- a/tests/scripts/ptc.sh +++ b/tests/scripts/ptc.sh @@ -10,28 +10,34 @@ echo "DON'T PUSH ANY OF THESE CHANGES TO THE REPO!!!!!!!!" echo "if you push these changes, I'll slap your butt" # remove some files not suitable for PDF: -rm ../library/data_structures/bit_uncommon/rupq.hpp -rm ../library/data_structures/bit_uncommon/rurq.hpp -rm ../library/data_structures/seg_tree.png -rm ../library/data_structures/seg_tree_uncommon/distinct_query.hpp -rm ../library/data_structures/seg_tree_uncommon/implicit.hpp -rm ../library/data_structures/seg_tree_uncommon/kth_smallest_query.hpp -rm ../library/data_structures/uncommon/mode_query.hpp -rm ../library/data_structures/uncommon/priority_queue_of_updates.hpp -rm ../library/graphs/strongly_connected_components/add_edges_strongly_connected.hpp -rm ../library/graphs/functional_graph_processor.hpp -rm ../library/math/derangements.hpp -rm ../library/math/num_distinct_subsequences.hpp -rm ../library/math/partitions.hpp -rm ../library/monotonic_stack/cartesian_k_ary_tree.hpp -rm ../library/monotonic_stack/max_rect_histogram.hpp -rm ../library/monotonic_stack/cartesian_binary_tree_after.png -rm ../library/monotonic_stack/mono_stack_ri.png -rm ../library/strings/manacher/longest_palindrome_query.hpp -rm -rf ../library/trees/centroid_decomp_uncommon/ -rm -rf ../library/trees/edge_centroid_decomp_uncommon/ -rm -rf ../library/trees/ladder_decomposition/ladder_decomposition.hpp -rm ../library/trees/linear_kth_path.hpp +rm ../library/data_structures/bit_uncommon/rupq.hpp || exit 1 +rm ../library/data_structures/bit_uncommon/rurq.hpp || exit 1 +rm ../library/data_structures/seg_tree.png || exit 1 +rm ../library/data_structures/seg_tree_uncommon/distinct_query.hpp || exit 1 +rm ../library/data_structures/seg_tree_uncommon/implicit.hpp || exit 1 +rm ../library/data_structures/seg_tree_uncommon/kth_smallest_query.hpp || exit 1 +rm ../library/data_structures/uncommon/mode_query.hpp || exit 1 +rm ../library/data_structures/uncommon/priority_queue_of_updates.hpp || exit 1 +rm ../library/graphs/strongly_connected_components/add_edges_strongly_connected.hpp || exit 1 +rm ../library/graphs/functional_graph_processor.hpp || exit 1 +rm ../library/math/derangements.hpp || exit 1 +rm ../library/math/num_distinct_subsequences.hpp || exit 1 +rm ../library/math/partitions.hpp || exit 1 +rm ../library/monotonic_stack/cartesian_k_ary_tree.hpp || exit 1 +rm ../library/monotonic_stack/max_rect_histogram.hpp || exit 1 +rm ../library/monotonic_stack/cartesian_binary_tree_after.png || exit 1 +rm ../library/monotonic_stack/mono_stack_ri.png || exit 1 +rm ../library/strings/manacher/longest_palindrome_query.hpp || exit 1 +rm ../library/trees/centroid_decomp_uncommon/count_paths_per_length.hpp || exit 1 +rm ../library/trees/centroid_decomp_uncommon/count_paths_per_node.hpp || exit 1 +rm ../library/trees/centroid_decomp_uncommon/lca.hpp || exit 1 +rm ../library/trees/edge_centroid_decomp_uncommon/README.md || exit 1 +rm ../library/trees/edge_centroid_decomp_uncommon/contour_range_query.hpp || exit 1 +rm ../library/trees/edge_centroid_decomp_uncommon/contour_range_update.hpp || exit 1 +rm ../library/trees/edge_centroid_decomp_uncommon/count_paths_per_length.hpp || exit 1 +rm ../library/trees/edge_centroid_decomp_uncommon/sum_adjacent.hpp || exit 1 +rm ../library/trees/ladder_decomposition/ladder_decomposition.hpp || exit 1 +rm ../library/trees/linear_kth_path.hpp || exit 1 # remove links in comments: these aren't useful in the PDF, and are usually the # longest words which extend into the next column From d948325702a8e8ecec87499ecf202fd815b23a0b Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 15 Dec 2024 12:50:36 -0600 Subject: [PATCH 49/57] fix --- tests/scripts/ptc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/ptc.sh b/tests/scripts/ptc.sh index e9dbde79..15458292 100755 --- a/tests/scripts/ptc.sh +++ b/tests/scripts/ptc.sh @@ -18,7 +18,7 @@ rm ../library/data_structures/seg_tree_uncommon/implicit.hpp || exit 1 rm ../library/data_structures/seg_tree_uncommon/kth_smallest_query.hpp || exit 1 rm ../library/data_structures/uncommon/mode_query.hpp || exit 1 rm ../library/data_structures/uncommon/priority_queue_of_updates.hpp || exit 1 -rm ../library/graphs/strongly_connected_components/add_edges_strongly_connected.hpp || exit 1 +rm ../library/graphs/scc/add_edges_strongly_connected.hpp || exit 1 rm ../library/graphs/functional_graph_processor.hpp || exit 1 rm ../library/math/derangements.hpp || exit 1 rm ../library/math/num_distinct_subsequences.hpp || exit 1 From 399296ea01d58ab65a48848cf4befe510fe9dd5a Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 15 Dec 2024 12:55:22 -0600 Subject: [PATCH 50/57] remove slow test LOL --- .../strings/longest_common_substring.test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/library_checker_aizu_tests/strings/longest_common_substring.test.cpp b/tests/library_checker_aizu_tests/strings/longest_common_substring.test.cpp index 79cd3a4a..e8ad8e6e 100644 --- a/tests/library_checker_aizu_tests/strings/longest_common_substring.test.cpp +++ b/tests/library_checker_aizu_tests/strings/longest_common_substring.test.cpp @@ -12,7 +12,7 @@ int main() { pair substr_s = {0, 0}, substr_t = {0, 0}; for (int i = 0; i < sz(sf_a.lcp); i++) { if (both[sf_a.sa[i]] == '$' || - both[sf_a.sa[i + 1]] == '$') + both[sf_a.sa[i + 1]] == '$') continue; bool before_in_s = (sf_a.sa[i] < sz(s)); bool after_in_s = (sf_a.sa[i + 1] < sz(s)); @@ -20,7 +20,7 @@ int main() { if (sf_a.lcp[i] > substr_s.second - substr_s.first) { substr_s = {sf_a.sa[i], sf_a.sa[i] + sf_a.lcp[i]}; substr_t = { - sf_a.sa[i + 1], sf_a.sa[i + 1] + sf_a.lcp[i]}; + sf_a.sa[i + 1], sf_a.sa[i + 1] + sf_a.lcp[i]}; if (after_in_s) swap(substr_s, substr_t); substr_t.first -= int(sz(s)) + 1; substr_t.second -= int(sz(s)) + 1; From 1aa118bf6c5d37f7620cf5492933dc05ed74a05f Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 15 Dec 2024 12:56:08 -0600 Subject: [PATCH 51/57] another fix --- tests/scripts/ptc.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/scripts/ptc.sh b/tests/scripts/ptc.sh index 15458292..196bce8b 100755 --- a/tests/scripts/ptc.sh +++ b/tests/scripts/ptc.sh @@ -30,7 +30,6 @@ rm ../library/monotonic_stack/mono_stack_ri.png || exit 1 rm ../library/strings/manacher/longest_palindrome_query.hpp || exit 1 rm ../library/trees/centroid_decomp_uncommon/count_paths_per_length.hpp || exit 1 rm ../library/trees/centroid_decomp_uncommon/count_paths_per_node.hpp || exit 1 -rm ../library/trees/centroid_decomp_uncommon/lca.hpp || exit 1 rm ../library/trees/edge_centroid_decomp_uncommon/README.md || exit 1 rm ../library/trees/edge_centroid_decomp_uncommon/contour_range_query.hpp || exit 1 rm ../library/trees/edge_centroid_decomp_uncommon/contour_range_update.hpp || exit 1 From b27cc435c73cef42945efa503a630e9ee718e5fb Mon Sep 17 00:00:00 2001 From: GitHub Date: Sun, 15 Dec 2024 19:25:51 +0000 Subject: [PATCH 52/57] [auto-verifier] verify commit 1aa118bf6c5d37f7620cf5492933dc05ed74a05f --- .verify-helper/timestamps.remote.json | 36 +++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index 3e89fa2b..8b68a50a 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -38,10 +38,10 @@ "tests/library_checker_aizu_tests/data_structures/persistent_seg_tree.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/data_structures/pq_ds_undo_sliding_window.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/data_structures/pq_ds_undo_with_dsu.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/data_structures/range_parallel_dsu.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/data_structures/range_parallel_dsu.test.cpp": "2024-12-15 12:37:34 -0600", "tests/library_checker_aizu_tests/data_structures/rmq_disjoint_sparse_table.test.cpp": "2024-12-15 09:26:21 -0600", -"tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp": "2024-12-15 09:26:21 -0600", -"tests/library_checker_aizu_tests/data_structures/rmq_sparse_table.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp": "2024-12-15 12:37:34 -0600", +"tests/library_checker_aizu_tests/data_structures/rmq_sparse_table.test.cpp": "2024-12-15 12:37:34 -0600", "tests/library_checker_aizu_tests/data_structures/rmq_sparse_table_inc.test.cpp": "2024-12-15 09:26:21 -0600", "tests/library_checker_aizu_tests/data_structures/simple_tree.test.cpp": "2024-12-14 15:47:13 -0600", "tests/library_checker_aizu_tests/data_structures/simple_tree_inc.test.cpp": "2024-12-14 15:47:13 -0600", @@ -54,21 +54,21 @@ "tests/library_checker_aizu_tests/graphs/connected_components_of_complement_graph.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/graphs/dijkstra_aizu.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/graphs/dijkstra_lib_checker.test.cpp": "2024-12-14 19:50:29 -0600", -"tests/library_checker_aizu_tests/graphs/directed_cycle.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/graphs/directed_cycle.test.cpp": "2024-12-15 12:40:15 -0600", "tests/library_checker_aizu_tests/graphs/enumerate_triangles.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/graphs/hopcroft_karp_aizu.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/graphs/hopcroft_karp_lib_checker.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/graphs/mst.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp": "2024-12-15 09:26:21 -0600", -"tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp": "2024-12-15 09:26:21 -0600", -"tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp": "2024-12-15 12:40:15 -0600", +"tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp": "2024-12-15 12:40:15 -0600", +"tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp": "2024-12-15 12:40:15 -0600", "tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp": "2024-12-15 09:01:54 -0600", -"tests/library_checker_aizu_tests/handmade_tests/count_paths_forest.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/handmade_tests/count_paths_forest.test.cpp": "2024-12-15 12:37:34 -0600", "tests/library_checker_aizu_tests/handmade_tests/dsu_size.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/handmade_tests/dynamic_bitset.test.cpp": "2024-11-22 10:47:44 -0600", -"tests/library_checker_aizu_tests/handmade_tests/edge_cd_small_trees.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/handmade_tests/edge_cd_small_trees.test.cpp": "2024-12-15 12:37:34 -0600", "tests/library_checker_aizu_tests/handmade_tests/fib_matrix_expo.test.cpp": "2024-12-14 19:50:29 -0600", -"tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp": "2024-12-15 12:37:34 -0600", "tests/library_checker_aizu_tests/handmade_tests/lca_ladder_forest.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/handmade_tests/manacher.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/handmade_tests/merge_st_and_wavelet.test.cpp": "2024-12-14 19:50:29 -0600", @@ -86,7 +86,7 @@ "tests/library_checker_aizu_tests/loops/supermasks.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/binary_exponentiation_mod.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/binary_matrix_mult.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/math/count_paths.test.cpp": "2024-12-10 20:34:52 -0600", +"tests/library_checker_aizu_tests/math/count_paths.test.cpp": "2024-12-15 12:37:34 -0600", "tests/library_checker_aizu_tests/math/derangement.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/matrix_determinant.test.cpp": "2024-12-14 15:47:13 -0600", "tests/library_checker_aizu_tests/math/matrix_mult.test.cpp": "2024-11-17 14:04:03 -0600", @@ -102,9 +102,9 @@ "tests/library_checker_aizu_tests/math/tetration.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/totient.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_binary_tree.test.cpp": "2024-12-14 19:50:29 -0600", -"tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_k_ary_tree.test.cpp": "2024-12-15 09:26:21 -0600", -"tests/library_checker_aizu_tests/monotonic_stack_related/count_rectangles.test.cpp": "2024-12-15 09:26:21 -0600", -"tests/library_checker_aizu_tests/monotonic_stack_related/max_rect_histogram.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_k_ary_tree.test.cpp": "2024-12-15 12:37:34 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/count_rectangles.test.cpp": "2024-12-15 12:37:34 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/max_rect_histogram.test.cpp": "2024-12-15 12:37:34 -0600", "tests/library_checker_aizu_tests/strings/kmp.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/strings/lcp_array.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/strings/lcp_query_palindrome.test.cpp": "2024-12-14 19:50:29 -0600", @@ -118,19 +118,19 @@ "tests/library_checker_aizu_tests/strings/sa_cmp.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/strings/sa_sort_pairs.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/strings/single_matching_bs.test.cpp": "2024-12-14 19:50:29 -0600", -"tests/library_checker_aizu_tests/strings/suffix_array.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/strings/suffix_array.test.cpp": "2024-12-15 12:37:34 -0600", "tests/library_checker_aizu_tests/strings/suffix_array_short.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/strings/trie.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/strings/wildcard_pattern_matching.test.cpp": "2024-12-14 19:50:29 -0600", -"tests/library_checker_aizu_tests/trees/count_paths_per_length.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/trees/count_paths_per_length.test.cpp": "2024-12-15 12:37:34 -0600", "tests/library_checker_aizu_tests/trees/edge_cd_contour_range_query.test.cpp": "2024-12-14 18:43:21 -0600", "tests/library_checker_aizu_tests/trees/edge_cd_contour_range_update.test.cpp": "2024-12-14 18:43:21 -0600", "tests/library_checker_aizu_tests/trees/edge_cd_count_paths_per_length.test.cpp": "2024-12-14 18:43:21 -0600", "tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp": "2024-12-14 18:43:21 -0600", "tests/library_checker_aizu_tests/trees/kth_path_ladder.test.cpp": "2024-12-15 09:26:21 -0600", "tests/library_checker_aizu_tests/trees/kth_path_linear.test.cpp": "2024-12-15 09:26:21 -0600", -"tests/library_checker_aizu_tests/trees/kth_path_tree_lift.test.cpp": "2024-12-15 09:26:21 -0600", +"tests/library_checker_aizu_tests/trees/kth_path_tree_lift.test.cpp": "2024-12-15 12:37:34 -0600", "tests/library_checker_aizu_tests/trees/lca_all_methods_aizu.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/trees/lca_all_methods_lib_checker.test.cpp": "2024-12-14 19:50:29 -0600", -"tests/library_checker_aizu_tests/trees/subtree_isomorphism.test.cpp": "2024-12-15 09:26:21 -0600" +"tests/library_checker_aizu_tests/trees/subtree_isomorphism.test.cpp": "2024-12-15 12:37:34 -0600" } \ No newline at end of file From 65b45caac28d56f2e658df44c98319b06e488fb8 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 15 Dec 2024 13:39:10 -0600 Subject: [PATCH 53/57] speedup --- library/math/matrix_related/xor_basis_unordered.hpp | 2 +- .../math/matrix_related/xor_basis_unordered_intersection.hpp | 4 ++-- .../strings/longest_common_substring.test.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/library/math/matrix_related/xor_basis_unordered.hpp b/library/math/matrix_related/xor_basis_unordered.hpp index 01a114dc..9114ba76 100644 --- a/library/math/matrix_related/xor_basis_unordered.hpp +++ b/library/math/matrix_related/xor_basis_unordered.hpp @@ -12,7 +12,7 @@ //! @time O(32) or O(64) //! @space O(32) or O(64) template struct basis { - vector b; + basic_string b; T shrink(T v) { for (T x : b) v = min(v, v ^ x); return v; diff --git a/library/math/matrix_related/xor_basis_unordered_intersection.hpp b/library/math/matrix_related/xor_basis_unordered_intersection.hpp index adf8ee75..e6ac47b9 100644 --- a/library/math/matrix_related/xor_basis_unordered_intersection.hpp +++ b/library/math/matrix_related/xor_basis_unordered_intersection.hpp @@ -6,8 +6,8 @@ template basis intersection(const basis& u, const basis& v) { - vector> w(sz(u.b)); - rep(i, 0, sz(w)) w[i] = {u.b[i], u.b[i]}; + basic_string> w; + for (T e : u.b) w.push_back({e, e}); basis res; for (T e : v.b) { T s = 0; diff --git a/tests/library_checker_aizu_tests/strings/longest_common_substring.test.cpp b/tests/library_checker_aizu_tests/strings/longest_common_substring.test.cpp index e8ad8e6e..79cd3a4a 100644 --- a/tests/library_checker_aizu_tests/strings/longest_common_substring.test.cpp +++ b/tests/library_checker_aizu_tests/strings/longest_common_substring.test.cpp @@ -12,7 +12,7 @@ int main() { pair substr_s = {0, 0}, substr_t = {0, 0}; for (int i = 0; i < sz(sf_a.lcp); i++) { if (both[sf_a.sa[i]] == '$' || - both[sf_a.sa[i + 1]] == '$') + both[sf_a.sa[i + 1]] == '$') continue; bool before_in_s = (sf_a.sa[i] < sz(s)); bool after_in_s = (sf_a.sa[i + 1] < sz(s)); @@ -20,7 +20,7 @@ int main() { if (sf_a.lcp[i] > substr_s.second - substr_s.first) { substr_s = {sf_a.sa[i], sf_a.sa[i] + sf_a.lcp[i]}; substr_t = { - sf_a.sa[i + 1], sf_a.sa[i + 1] + sf_a.lcp[i]}; + sf_a.sa[i + 1], sf_a.sa[i + 1] + sf_a.lcp[i]}; if (after_in_s) swap(substr_s, substr_t); substr_t.first -= int(sz(s)) + 1; substr_t.second -= int(sz(s)) + 1; From 2ba1a33e37a6cfc989c0afae9515d522c58a296b Mon Sep 17 00:00:00 2001 From: GitHub Date: Sun, 15 Dec 2024 19:45:00 +0000 Subject: [PATCH 54/57] [auto-verifier] verify commit 65b45caac28d56f2e658df44c98319b06e488fb8 --- .verify-helper/timestamps.remote.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index 8b68a50a..41c9c00f 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -101,6 +101,8 @@ "tests/library_checker_aizu_tests/math/solve_linear_mod.test.cpp": "2024-12-14 15:47:13 -0600", "tests/library_checker_aizu_tests/math/tetration.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/totient.test.cpp": "2024-11-17 14:04:03 -0600", +"tests/library_checker_aizu_tests/math/xor_basis.test.cpp": "2024-12-15 13:39:10 -0600", +"tests/library_checker_aizu_tests/math/xor_basis_intersection.test.cpp": "2024-12-15 13:39:10 -0600", "tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_binary_tree.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_k_ary_tree.test.cpp": "2024-12-15 12:37:34 -0600", "tests/library_checker_aizu_tests/monotonic_stack_related/count_rectangles.test.cpp": "2024-12-15 12:37:34 -0600", From f11589257e5f98c56dd7fcba095b57d12a15d63b Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 15 Dec 2024 13:54:46 -0600 Subject: [PATCH 55/57] trying this --- .../strings/longest_common_substring.test.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/tests/library_checker_aizu_tests/strings/longest_common_substring.test.cpp b/tests/library_checker_aizu_tests/strings/longest_common_substring.test.cpp index 79cd3a4a..0902301d 100644 --- a/tests/library_checker_aizu_tests/strings/longest_common_substring.test.cpp +++ b/tests/library_checker_aizu_tests/strings/longest_common_substring.test.cpp @@ -1,26 +1,23 @@ #define PROBLEM \ "https://judge.yosupo.jp/problem/longest_common_substring" #include "../template.hpp" -#include "../../../library/strings/suffix_array/suffix_array_query.hpp" +#include "../../../library/strings/suffix_array/suffix_array.hpp" int main() { cin.tie(0)->sync_with_stdio(0); string s, t; cin >> s >> t; string both = s + '$' + t; auto [sa, sa_inv, lcp] = get_sa(both, 256); - sa_query sf_a(both, sa, sa_inv, lcp); pair substr_s = {0, 0}, substr_t = {0, 0}; - for (int i = 0; i < sz(sf_a.lcp); i++) { - if (both[sf_a.sa[i]] == '$' || - both[sf_a.sa[i + 1]] == '$') + for (int i = 0; i < sz(lcp); i++) { + if (both[sa[i]] == '$' || both[sa[i + 1]] == '$') continue; - bool before_in_s = (sf_a.sa[i] < sz(s)); - bool after_in_s = (sf_a.sa[i + 1] < sz(s)); + bool before_in_s = (sa[i] < sz(s)); + bool after_in_s = (sa[i + 1] < sz(s)); if (before_in_s ^ after_in_s) { - if (sf_a.lcp[i] > substr_s.second - substr_s.first) { - substr_s = {sf_a.sa[i], sf_a.sa[i] + sf_a.lcp[i]}; - substr_t = { - sf_a.sa[i + 1], sf_a.sa[i + 1] + sf_a.lcp[i]}; + if (lcp[i] > substr_s.second - substr_s.first) { + substr_s = {sa[i], sa[i] + lcp[i]}; + substr_t = {sa[i + 1], sa[i + 1] + lcp[i]}; if (after_in_s) swap(substr_s, substr_t); substr_t.first -= int(sz(s)) + 1; substr_t.second -= int(sz(s)) + 1; From b90fc793bace844f05680afa8947030ff3234547 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 15 Dec 2024 14:28:24 -0600 Subject: [PATCH 56/57] actually it doesn't work now --- library/math/matrix_related/xor_basis_unordered.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/library/math/matrix_related/xor_basis_unordered.hpp b/library/math/matrix_related/xor_basis_unordered.hpp index 9114ba76..c1c85a4d 100644 --- a/library/math/matrix_related/xor_basis_unordered.hpp +++ b/library/math/matrix_related/xor_basis_unordered.hpp @@ -4,7 +4,6 @@ //! @code //! basis b1; //! basis b2; -//! basis> b3; //! @endcode //! b.shrink(v) == b.shrink(b.shrink(v)) //! for x in b.b: (bit_floor(x)&b.shrink(v))==0 From c6ad2313f5454e58a437893febac58941f8cf4ce Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 15 Dec 2024 14:31:05 -0600 Subject: [PATCH 57/57] fix --- tests/.config/.cppcheck_suppression_list | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/.config/.cppcheck_suppression_list b/tests/.config/.cppcheck_suppression_list index e069fe4a..195c11de 100644 --- a/tests/.config/.cppcheck_suppression_list +++ b/tests/.config/.cppcheck_suppression_list @@ -10,7 +10,7 @@ unusedStructMember:../library/trees/ladder_decomposition/linear_kth_par.hpp:17 unusedStructMember:../library/data_structures/dsu/dsu_bipartite.hpp:9 unusedStructMember:../library/trees/linear_lca.hpp:15 unusedScopedObject:../library/trees/centroid_decomp_uncommon/count_paths_per_length.hpp:12 -unusedScopedObject:library_checker_aizu_tests/cd_asserts.hpp:5 +unusedScopedObject:library_checker_aizu_tests/cd_asserts.hpp:6 unusedScopedObject:../library/trees/centroid_decomp_uncommon/count_paths_per_node.hpp:14 unusedScopedObject:library_checker_aizu_tests/trees/centroid_path_dist.test.cpp:29 unusedScopedObject:../library/trees/edge_centroid_decomp_uncommon/count_paths_per_length.hpp:13 @@ -21,9 +21,10 @@ unusedScopedObject:library_checker_aizu_tests/trees/cd_jump_on_tree.test.cpp:58 arrayIndexOutOfBoundsCond:library_checker_aizu_tests/math/linear_prime_sieve.test.cpp:17 negativeContainerIndex:../library/strings/suffix_array/burrows_wheeler.hpp:50 useStlAlgorithm:../kactl/content/numerical/FastFourierTransform.h:53 -useStlAlgorithm:../library/graphs/strongly_connected_components/add_edges_strongly_connected.hpp:58 +useStlAlgorithm:../library/graphs/scc/add_edges_strongly_connected.hpp:58 useStlAlgorithm:../library/math/matrix_related/row_reduce.hpp:28 -useStlAlgorithm:../library/math/count_paths/count_paths_triangle.hpp:23 +useStlAlgorithm:../library/math/count_paths/count_paths_triangle.hpp:24 +useStlAlgorithm:../library/math/matrix_related/xor_basis_unordered_intersection.hpp:10 shadowFunction:../kactl/content/graph/BinaryLifting.h:17 unknownMacro:../kactl/content/graph/BinaryLifting.h:18 constParameter:../kactl/content/graph/BinaryLifting.h:29