CSP-S 2022 Solutions
The problems in this set require careful handling of edge cases and efficient algorithms. Below are the solutions for all four tasks.
T1: Holiday Plan
Given constraints n ≤ 2.5 × 103, an O(n2) approach is feasible.
We enumerate the middle two vertices B and C. For a valid pair (B, C), we pre‑compute the set of possible A (from B) and possible D ...
Posted on Thu, 10 Sep 2026 16:44:49 +0000 by dscapuano
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
Introduction to Segment Trees and Range Queries
Range Extremum Queries and Algorithmic ChoicesRange Maximum/Minimum Query (RMQ) problems involve processing an array of size n to handle multiple range queries and bulk modifications. Different data structures offer varying trade-offs:Brute Force: Simple implementation suitable for small datasets, but query performance is poor.Binary Indexed Tr ...
Posted on Wed, 13 May 2026 21:56:16 +0000 by Niruth