TypeScript Fundamentals for Competitive Programming

Basic Types Primitive types in TypeScript include number, string, boolean, null, undefined, and symbol. Object types encompass arrays, objects, functions, and more. You can define custom complex object types using type aliases. // Primitive types: number/string/boolean/null/undefined/symbol // Object types: arrays, objects, functions, etc. ty ...

Posted on Mon, 28 Sep 2026 16:22:18 +0000 by anthony88guy

Solutions and Analysis for AtCoder Beginner Contest 311

A - First ABC The problem requires identifying the minimum 1-indexed position within a given string S where the characters 'A', 'B', and 'C' have all appeared at least once. The string length N is also provided. To solve this, we can iterate through the string from its beginning. As we process each character, we need a way to track whether 'A', ...

Posted on Mon, 28 Sep 2026 16:13:09 +0000 by cpd259

Common C++ Templates for Competitive Programming

Number Theory Utilities Greatest Common Divisor int gcd(int a, int b) { while (b) { int temp = b; b = a % b; a = temp; } return a; } Least Common Multiple int lcm(int a, int b) { return a / gcd(a, b) * b; } Fast Exponentiation long long power(long long base, long long exp) { long long result = 1; ...

Posted on Sun, 27 Sep 2026 16:13:40 +0000 by spambadger

Common Input/Output Methods for C++ in ACM Competition Mode

Common Input/Output Primitives cin cin is C++'s standrad input stream object. It automatically treats spaces, tabs, and newlines as input separators. #include <iostream> using namespace std; int main() { int input_num; cin >> input_num; cout << input_num << endl; return 0; } getline() When reading strin ...

Posted on Thu, 24 Sep 2026 16:39:10 +0000 by VLE79E

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