From 6d37abbd52439e9f2d33b0117a0bd32d3c2e01e1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Nov 2025 18:18:19 +0000 Subject: [PATCH 1/4] Initial plan From 7fcfe28381152a39e94942cde7e70fd53537eb2f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Nov 2025 18:23:35 +0000 Subject: [PATCH 2/4] Modify find_first and find_last to return optional Co-authored-by: ei1333 <11004413+ei1333@users.noreply.github.com> --- structure/segment-tree/lazy-segment-tree.hpp | 12 ++++++------ structure/segment-tree/segment-tree.hpp | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/structure/segment-tree/lazy-segment-tree.hpp b/structure/segment-tree/lazy-segment-tree.hpp index 468209ec..1ca00072 100644 --- a/structure/segment-tree/lazy-segment-tree.hpp +++ b/structure/segment-tree/lazy-segment-tree.hpp @@ -116,8 +116,8 @@ struct LazySegmentTree { } template - int find_first(int l, const C& check) { - if (l >= n) return n; + optional find_first(int l, const C& check) { + if (l >= n) return nullopt; l += sz; for (int i = height; i > 0; i--) propagate(l >> i); S sum = m.e(); @@ -137,12 +137,12 @@ struct LazySegmentTree { } sum = m.op(sum, data[l++]); } while ((l & -l) != l); - return n; + return nullopt; } template - int find_last(int r, const C& check) { - if (r <= 0) return -1; + optional find_last(int r, const C& check) { + if (r <= 0) return nullopt; r += sz; for (int i = height; i > 0; i--) propagate((r - 1) >> i); S sum = m.e(); @@ -163,6 +163,6 @@ struct LazySegmentTree { } sum = m.op(data[r], sum); } while ((r & -r) != r); - return -1; + return nullopt; } }; diff --git a/structure/segment-tree/segment-tree.hpp b/structure/segment-tree/segment-tree.hpp index 67a74cd9..0a3e9d60 100644 --- a/structure/segment-tree/segment-tree.hpp +++ b/structure/segment-tree/segment-tree.hpp @@ -66,8 +66,8 @@ struct SegmentTree { S all_prod() const { return seg[1]; } template - int find_first(int l, const C& check) const { - if (l >= n) return n; + optional find_first(int l, const C& check) const { + if (l >= n) return nullopt; l += sz; S sum = m.e(); do { @@ -85,12 +85,12 @@ struct SegmentTree { } sum = m.op(sum, seg[l++]); } while ((l & -l) != l); - return n; + return nullopt; } template - int find_last(int r, const C& check) const { - if (r <= 0) return -1; + optional find_last(int r, const C& check) const { + if (r <= 0) return nullopt; r += sz; S sum = m.e(); do { @@ -109,6 +109,6 @@ struct SegmentTree { } sum = m.op(seg[r], sum); } while ((r & -r) != r); - return -1; + return nullopt; } }; From a0e9427e066946f366b8876121a5e8728e11cd61 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Nov 2025 18:26:50 +0000 Subject: [PATCH 3/4] Final verification complete Co-authored-by: ei1333 <11004413+ei1333@users.noreply.github.com> --- _codeql_detected_source_root | 1 + 1 file changed, 1 insertion(+) create mode 120000 _codeql_detected_source_root diff --git a/_codeql_detected_source_root b/_codeql_detected_source_root new file mode 120000 index 00000000..945c9b46 --- /dev/null +++ b/_codeql_detected_source_root @@ -0,0 +1 @@ +. \ No newline at end of file From e829ae786120a269fd0620c14f17d3ed7c9595fa Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Nov 2025 18:27:08 +0000 Subject: [PATCH 4/4] Remove CodeQL artifact --- _codeql_detected_source_root | 1 - 1 file changed, 1 deletion(-) delete mode 120000 _codeql_detected_source_root diff --git a/_codeql_detected_source_root b/_codeql_detected_source_root deleted file mode 120000 index 945c9b46..00000000 --- a/_codeql_detected_source_root +++ /dev/null @@ -1 +0,0 @@ -. \ No newline at end of file