Advanced Interval Data Structures for Algorithmic Challenges
Plane Closest Pair
A standard approach utilizes divide and conquer strategies. Sort all points by their x-corodinate recursively split the set into two halves. After solving subproblems, examine points near the dividing line that could potentially form a shorter pair then the current minimum found.
const int MAX_PTS = 250005;
struct Point {
...
Posted on Sat, 12 Sep 2026 16:24:10 +0000 by Kyori
Solutions to AtCoder Beginner Contest 055 Problems
Problem A
Each meal costs 800 yen. For every 15 meals purchased, a refund of 200 yen is issued. Given $ x $, the total number of meals consumed, compute the net expenditure.
The formula is:
$$
800x - \left\lfloor \frac{x}{15} \right\rfloor \cdot 200
$$
Problem B
After $ N $ workouts, where initial strength is 1 and each $ i $-th workout multipl ...
Posted on Fri, 11 Sep 2026 16:45:57 +0000 by YOUAREtehSCENE
Understanding Dynamic Programming: From Recurrence to Optimization
Core Ideas of Dynamic Programming
Dynamic programming (DP) requires moving beyond memorized templates. The essence is decomposing a problem into overlapping subproblems, defining states, and establishing transition equations. Three fundamental steps drive most DP solutions:
State definition (what each dp entry represents)
Table filling and tra ...
Posted on Thu, 10 Sep 2026 16:33:18 +0000 by sgbalsekar
Advanced Data Structures for Competitive Programming
Li Chao Segment Tree
Problem: Maintain a collection S of linear functions with the following operations:
Insert a linear function f(x) = kx + b over a range [l, r]
Query maxf∈S f(x) for a given x
The naive approach decomposes a linear function's range into O(log n) segment tree nodes and stores all functions at each node. However, this can le ...
Posted on Mon, 07 Sep 2026 16:41:04 +0000 by Goldeneye
Optimizing Counting of Unique Item Sets in Train Compartments
Problem Statement
A train has n compartments numbered from 1 to n. Each compartment requires a set of items, where item numbers range from 1 to m. A vendor named Alice is assigned to any continuous sequence of compartments to sell goods. For any such sequence, she must prepare all items required by those compartments and create a unique chant f ...
Posted on Mon, 07 Sep 2026 16:18:29 +0000 by visualAd
Solution Set for the 2023 SMU RoboCom-CAIP Selection Contest
Problem A: Maximum Value Boundary Analysis
In this problem, we need to calculate the sum of counts $f(k)$ for pairs $(i, j)$ that satisfy specific boundary conditions related to two arrays $A$ and $B$. Let $f(k)$ represent the number of valid pairs where the second index $j$ equals $k$. We define $last\_k$ as the index where the maximum value o ...
Posted on Fri, 04 Sep 2026 16:45:03 +0000 by dhaselho
Optimizing C++ I/O Operations and Sorting Techniques
Improving C++ I/O Performance
In C++, there are two primary methods for input and output operations: the C-style functions (scanf and printf) and the C++ stream-based methods (cin and cout). When using the universal header file <iostream>, these approaches can be used interchangeably.
Although C++ inherits similarities from C, the stream- ...
Posted on Fri, 04 Sep 2026 16:13:24 +0000 by magi
Minimum Distance to Deliver All Orders in a Tree Network
In a tree-structured neighborhood where the root represents the delivery station, a courier must visit all requested delivery nodes at least once. The goal is to compute, after each new delivery request, the shortest total distance required to deliver all orders so far—without needing to return to the root.
The key insight is that traversing al ...
Posted on Thu, 03 Sep 2026 16:29:39 +0000 by Fritz.fx
Maximum Size Set with No Fixed Differences
Problem Statement
Given three positive integers $n$, $x$, and $y$, we need to find the maximum size of a set $S$ satisfying:
$S \subseteq {1, 2, \ldots, n}$
For any $a \in S$ and $b \in S$, $|a - b| \neq x$ and $|a - b| \neq y$
Output the maximum possible cardinality of $S$.
Constraints: $1 \leq n \leq 10^9$, $1 \leq x, y \leq 22$
Observation ...
Posted on Wed, 02 Sep 2026 16:43:33 +0000 by mark bowen
Efficiently Counting Specific 4-Tuples from Input Triplets
This article addresses the problem of identifying and counting specific 4-tuples based on a given set of 3-tuples. Given a collection of M three-element tuples (a, b, c), the objective is to determine the total number of distinct 4-element tuples (x, y, z, w) that satisfy the following conditions:
(x, y, z) is one of the input 3-tuples.
The 3- ...
Posted on Wed, 02 Sep 2026 16:14:32 +0000 by PhilGDUK