Competitive Programming Problem Solutions: A Holiday Practice Log

Mock Contest Problem 1 Problem Overview Converting the constraints reveals two key requirements for any valid set: Must include the maximum power of each prime factor of n Must contain at least one pair of distinct prime factors Since the number of prime factors is much smaller than log(n), brute force search works effectively. Approach: Incl ...

Posted on Fri, 26 Jun 2026 17:15:55 +0000 by obay

Algorithm Implementation Challenges and Solutions

Exponential Calculation This solution calculates the power of 2 for a given non-negative integer n. Instead of iterating, we utilize bit shifting for efficiency. #include <iostream> int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int exponent; std::cin >> exponent; long long resul ...

Posted on Thu, 25 Jun 2026 17:46:32 +0000 by TheBrandon

Shortest Path with Time-Based Road Blockages

Problem Overview Given a graph with (n) intersections ((n \le 10^3)) and (m) bidirectional roads ((m \le 10^4)), a person named T moves first along a predetermined path (c_1, c_2, \ldots, c_g). Each road has a travel time (f[u][v]). When T traverses a road, that road becomes blocked for the entire duration of T's crossing. Luka starts from inte ...

Posted on Tue, 23 Jun 2026 17:27:31 +0000 by Nick~C

Graph Theory: Shortest Path Algorithms

No difference between shortest paths in directed and undirected graphs (undirected graph are special cases of directed graphs) Graph storage: dense graphs (adjacency matrix) && sparse graphs (adjacency list) I. Single-Source Shortest Path 1. All edge weights are positive - Dijkstra's Algorithm Handling multiple edges and self-loops ...

Posted on Sat, 20 Jun 2026 17:06:21 +0000 by PHP Newb

Identifying the Youngest Generation in a Family Tree

Given a family tree, the task is to output the smallest generation (youngest descendants) and list all members belonging to that generation. Input Format: The first line contains an integer N (1 ≤ N ≤ 100,000), the total number of family members, each assigned a unique ID from 1 to N. The second line provides N integers where the i-th integer r ...

Posted on Fri, 19 Jun 2026 17:57:12 +0000 by dm3

Algorithmic Review and Competition Strategies for NOIP

Contest preparation requires a structured approach to covering fundamental algorithms and optimizing problem-solving strategies. The following outlines core technical topics and execution practices essential for competitive programming. Core Algorithms and Data Structures Simulation and Mathematics High-precision arithmetic is critical for p ...

Posted on Mon, 15 Jun 2026 17:54:23 +0000 by press711

Algorithmic Solutions for String Processing, Greedy Maximization, and Graph Dependencies

Prefix Matching and Keyboard Layout Reconstruction This problem involves identifying possible next characters based on a given prefix and mapping them to a specific $4 \times 8$ grid layout. The core task is to filter a list of strings that start with a specific sequence and mark the character that immediately follows that sequence. #include &l ...

Posted on Sun, 07 Jun 2026 16:46:38 +0000 by rednax

Simple Graph Theory and Construction

Simple Graph Theory and Construction A Consider vertices with weight 2 as adding one to vertices with weight 1. Thus the problem is split into two parts: constructing the tree and adding one to vertices. In the first part, constructing the tree as balanced as possible is beneficial, as will be shown in the second step. Construction: Process DFS ...

Posted on Sun, 31 May 2026 16:28:06 +0000 by twostars

Tree Divide and Conquer: Point, Edge, and Divide Tree Techniques

Point and Edge Divide and Conquer Point and edge divide and conquer are algorithmic techniques that extend the concept of sequence divide and conquer to tree structures. The core idea involves selecting a "center" (a node or an edge) to partition the tree into smaller, independent sub-problems. To ensure efficiency and balance, we spe ...

Posted on Wed, 27 May 2026 16:26:54 +0000 by dakkonz

Solutions for the SXJ202507250900 Simulation Contest

Problem 1: Dumpling Purchase Optimization The problem reduces to a daily deciison: buy dumplings at the current price or rely on an earlier purchase plus storage cost. The total expense for day i if we buy on day j ≤ i is price[j] + c*(i - j). This can be rewritten as (price[j] - c*j) + c*i. Thus we can maintain the minimum value of price[j] - ...

Posted on Sat, 23 May 2026 19:20:05 +0000 by d_barszczak