NOI Online 2022 Contest Solutions: Monotone Stacks, Set Systems, and Multidimensional Partial Orders

Problem 1: Stack Elimination with Color Constraints Given a sequence where each element possesses a color and value, process multiple queries. For each query $[L, R]$, simulate a monotonic stack traversal from left to right: pop the top while it is less than or equal to the current value or shares the same color. Determine how many positions wi ...

Posted on Tue, 22 Sep 2026 16:39:41 +0000 by ldb358

Comparator and Verifier: A Pre-Contest Strategy

Comparator and Verifier "The prerequisite for using a comparator/verifier is that you must have a working brute force solution. Without it, these tools are ineffective." Application Background You have a brute force C++ code that produces correct results but is too slow for large datasets. You've also written an optimized non-brute force sol ...

Posted on Tue, 22 Sep 2026 16:19:53 +0000 by CodeJunkie88

Solutions to ARC143 Problems: Three Integers, Counting Grids, and Piles of Pebbles

T1 Three Integers Problem Statement Given three integers A, B, and C, there are two operations: Operation 1: Choose two numbers and decrement each by 1. Operation 2: Choose all three numbers and decrement each by 1. The goal is to reduce all three numbers to 0. If impossible, output -1. Solution Approach A key insight is that any operation sh ...

Posted on Sun, 20 Sep 2026 16:12:21 +0000 by evlive

Optimizing C++ I/O Performance for Competitive Programming

In competitive programming, the speed of input and output operations can be a deciding factor between an "Accepted" and a "Time Limit Exceeded" status. While standard C++ streams are convenient, their default behavior is often too slow for processing large datasets. This guide explores several layers of I/O optimization, fro ...

Posted on Sun, 20 Sep 2026 16:09:52 +0000 by Rangel

20240125 Construction Problem Solutions

P1734E First, analyze the second condition: rearrange it to $a_{r_1, c_1} - a_{r_1, c_2} \not\equiv a_{r_2, c_1} - a_{r_2, c_2} \pmod{n}$. Our goal is to ensure that the column-wise difference values between any two rows are distinct. We have not yet addressed conditions 1 and 3. Conddition 1 can be satisfied by taking all elements modulo $n$. ...

Posted on Mon, 14 Sep 2026 16:27:32 +0000 by Robkid

Virtual Judge Problem Set Solutions

A. Grid Ice Floor This problem requires analyzing the accessible states of each cell on a grid. When standing at position (i, j), there are exactly 5 possible movement states: Moving upward Moving downward Moving leftward Moving rightward Standing still We define dp[i][j][state] to indicate whether reaching cell (i, j) with a specific state i ...

Posted on Sun, 13 Sep 2026 16:14:50 +0000 by stringfield

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