Sparse Table for Range Minimum/Maximum Query

Range Minimum/Maximum Query (RMQ) The RMQ problem involves finding the minimum or maximum value within a specified range of an array of length n. Given multiple queries of the form RMQ(A, i, j), where i and j are indices in the array, the task is to return smallest or largest element between positions i and j. Sparse Table Algorithm The Sparse ...

Posted on Fri, 17 Jul 2026 17:14:57 +0000 by dharprog

Algorithmic Solutions: Interval Partitioning, Graph Matching, and Trie-Based Set Operations

Problem A: Large-Scale Simulation A pure simulation problem centered on game theory mechanics. The implementation involves directly modeling the described rules and state transitions. Problem B: Maximum Total Range for k-Partition Define the weight of a subarray as its range (maximum element minus minimum element). For each k from 1 to n, compu ...

Posted on Thu, 16 Jul 2026 16:19:13 +0000 by killfall

Maximum Subtree Sum with Tree Dynamic Programming

We are given a tree of (n) nodes, each carrying an integer weight (which may be negative). The task is to select a connected subgraph that forms a subtree and maximise the sum of the node weights inside it. The problem appears with two common variants: one that allows an empty selection (answer at least 0) and one that requires at least one nod ...

Posted on Mon, 13 Jul 2026 16:31:14 +0000 by rodin

Optimizing Laser Path and Diagonal Grid Separation Problems

When solving this problem, precision errors in floating-point comparisons led to multiple failed submissions despite correct algorithmic logic. The challenge lies in grouping monsters by their directional vectors and efficiently computing the number of targets hit by a laser fired in a specific direction. Monsters are represented as coordinate ...

Posted on Sat, 11 Jul 2026 17:06:05 +0000 by taha

AtCoder ABC 447 Contest Solutions

Problem D - Take ABC 2 An efficient approach involves processing the string from the end to identify and count valid "ABC" sequences. #include <vector> #include <string> #include <iostream> using namespace std; void processString() { string input; cin >> input; vector<int> posA, posB, posC; ...

Posted on Sat, 11 Jul 2026 16:17:57 +0000 by Sa177ir

Solution: QOJ-6322 / The 1st Universal Cup. Stage 12: Ōokayama - F. Forestry

Introduction This is a challenging problem that combines segment tree merging with dynamic programming optimization. While it follows a relatively standard template, the overall difficulty level is high. Prerequisites: Dynamic programming, tree-based DP, segmant tree with dynamic node allocation, segment tree merging. Problem link: Click here D ...

Posted on Fri, 10 Jul 2026 16:49:46 +0000 by Masna

Dynamic Programming Solutions for House Robber Problems: Linear, Circular, and Tree Variants

House Robber I The classic house robber problem involves selecting houses to rob such that adjacent houses cannot both be robbed, maximizing total profit. For each house, there are two choices: rob it or skip it. The decision at each position aims to maximize accumulated wealth. State Defniition: wealth[i] represents the maximum money obtainabl ...

Posted on Tue, 07 Jul 2026 17:10:21 +0000 by djelica

Analysis of Selected Competitive Programming Problems

[CTS2024] The Gate of All Beings This is a constructive problem on tree traversal. Observation of large test cases shows the answer does not exceed 3. It is posssible to traverse the entire tree with paths of length at most 3. The answer is typically 0 or 1, except for small trees or star-shaped graphs. For small n (≤ 8), a brute-force search o ...

Posted on Mon, 06 Jul 2026 16:00:40 +0000 by rilana

Dynamic Programming Strategies for Contiguous Subarray Problems

Dynamic programming solutions for contiguous subarray challenges typically analyze sequences where each element serves as the endpoint of potential subarrays. This approach efficiently leverages overlapping subproblems and optimal substructure properties. Maximum Subarray Sum Finding the largest sum of any contiguous subarray uses Kadane's algo ...

Posted on Sat, 04 Jul 2026 17:03:11 +0000 by faheemhameed

Graph Orientation, Permutation Cycle LCM, Interval Partitioning, and Card Sequence Matching

Directed Edge Orientation with Out-Degree ConstraintGiven an undirected graph, determine the number of ways to orient all edges such that every vertex has an out-degree of exactly 1. The result should be modulo 998244353.For such an orientation to exist, the number of edges must exactly equal the number of vertices, i.e., m = n. Furthermore, ev ...

Posted on Wed, 01 Jul 2026 17:40:45 +0000 by hairyjim