Solving the TENIS Problem from COCI 2018-2019 Finals
The problem determines which players can win a tournament across three courts with distinct rankings. A player defeats another if they have a better (lower) rank in any court.
Key Insight
Each player is represented by their worst (maximum) rank across all courts, denoted as $m_i$. The set of potential winners forms a contiguous prefix of player ...
Posted on Fri, 16 Oct 2026 16:30:35 +0000 by nick1
Heavy-Light Decomposition for Tree Path and Subtree Operations
DFS traversal establishes contiguous intervals for subtrees. When a node u is visited, all nodes within its subtree receive subsequent timestamps. Let entry[u] denote the discovery time and size[u] the subtree node count. The subtree of u perfectly maps to the array segment [entry[u], entry[u] + size[u] - 1]. Subtree modifications and queries ...
Posted on Sun, 11 Oct 2026 16:04:34 +0000 by PHP-beginner
HydroOJ Daily Problem #001
This article presents the solution for the first daily problem from HydroOJ (September 3, 2021): [COCI2018-2019 Final T4] TENIS.
Problem Statement
Vito is organizing a tennis tournament with n players (numbered 1 to n). He has ranking lists for three court types: clay, grass, and hard court. The tournament consists of n−1 matches. In each match ...
Posted on Mon, 05 Oct 2026 16:38:10 +0000 by june_c21
Competitive Programming Solutions: Graph Paths, DP, and Segment Trees
Problem A: Operations with Inversions
Greedy solution. Skipped for brevity.
Problem B: Optimal Shifts
Greedy solution. Skipped for brevity.
Problem C: Odd Process
Problem Statement: You have n numbers, each with a value a_i. You need to perform k rounds of operations where you can place a number into a bag (each number can only be placed once). ...
Posted on Tue, 29 Sep 2026 16:27:28 +0000 by Pilly
Subtree Updates with Parity Constraints and Geometric Convex Hull Validation
Subtree Interval Operations and Linear Transformations
Problem Analysis
In scenarios where operations target entire subtrees, a common technique is to linearize the tree into a DFS order sequence. This transformation maps a subtree rooted at node $v$ to a contiguous range $[dfn[v], dfn[v] + sz[v] - 1]$. Once linearized, range udpate and point q ...
Posted on Fri, 25 Sep 2026 16:05:59 +0000 by Moocat
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
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
Dynamic Programming and Advanced Data Structures
A
The problem involves matrices and their properties. The key insight is to treat four types of brackets as distinct invertible matrices.
Two strings can be concatenated if their product equals the identity matrix. While this is a necessary condition, it's not sufficient. However, hashing can serve as an effective heuristic.
We maintain prefix ...
Posted on Sat, 05 Sep 2026 16:36:49 +0000 by ziola
Programming Contest Problem Solutions: July 15, 2024
Problem 1: CF1607E
A straightforward problem that can be solved through direct simulation of the given process. The solution involves implementing the described algorithm step by step without requiring complex data structures or optimizations.
Problem 2: CF1614C
The solution leverages bitwise operations and segment trees to efficiently compute ...
Posted on Sat, 29 Aug 2026 16:48:55 +0000 by sava
Solutions for Codeforces Round 1053 (Div. 2) Problems A through E
Problem A: Incremental SubarrayBy examining the pattern of numbers, we observe that if the given sequence \(a\) does not form a contiguous interval, the result is always 1. Otherwise, we check the last element \(a_m\) of the sequence. The answer becomes \(n - a_m + 1\), representing the count of integers from \(a_m\) to \(n\).#include
using na ...
Posted on Wed, 26 Aug 2026 16:09:29 +0000 by james13009