SM Training Camp Notes (2024.11.15 ~ 2024.11.29)
DAY0 (2024.11.15)
Finally arriving at the camp.
T2 GYM104787M
First, we define a replica connected component as a connected component formed by traversing only nodes with index greater than n. It's not hard to observe that a replica connected component (green nodes) connects to several leaves with index less than n, and together with the origin ...
Posted on Fri, 10 Jul 2026 17:44:56 +0000 by raffael3d
Dynamic Programming Problems
It is clear that S represents the initial magic value, k is the number of selected items, and x is given in the problem.
Noting that x is large but k and n are small, we can define a state that tracks the i-th item, the number of selected items j, and the sum modulo k as l. The goal is to maximize the initial magic value, as higher values reduc ...
Posted on Thu, 09 Jul 2026 17:14:51 +0000 by Virii
Solutions for 2024 RoboCom CAIP Programming Skills Provincial Competition
RC-u1 Heat Wave
Problem Summary: Given daily maximum temperatures and the day of the week for the first day, count how many days have temperatures ≥ 35°C. Days falling on weekends (Saturday and Sunday) should be counted separately.
Solution: Iterate through the temperature data while tracking the current weekday. For each temperature ≥ 35, incr ...
Posted on Tue, 07 Jul 2026 17:58:05 +0000 by [UW] Jake
Calculating Binomial Expansion Coefficients Modulo 10007
This article addresses the problem of finding the coefficient of the $x^n y^m$ term in the expansion of the polynomial $(ax + by)^k$. The solution involves applying the binoimal theorem and calculating combinations modulo 10007.
Binomial Theorem Application
The binomial theorem states that $(x+y)^k = \sum_{i=0}^{k} \binom{k}{i} x^{k-i} y^i$. In ...
Posted on Mon, 06 Jul 2026 16:23:12 +0000 by fangfang
Dynamic Programming Problem Solutions
Unique Substrings in Wraparound String
Given a string p, find the number of unique non-empty substrings of p that are also substrings of the infinite wraparound string "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz...". The infinite string repeats the alphabet sequence cyclically.
DP Solution: We'll use a DP array where dp[i] r ...
Posted on Mon, 29 Jun 2026 17:55:59 +0000 by eashton123
Dynamic Programming Techniques for Knapsack Problems
0/1 Knapsack
Given N items and a knapsack with capacity V, each item can only be selected once. Item i has volume v[i] and value w[i]. Determine which items to select to maximize total value without exceeding the knapsack's volume.
Constraints:
0 < N, V ≤ 1000
0 < v[i], w[i] ≤ 1000
Time Complexity: O(N × V)
int n, m;
int f[100010], w[10 ...
Posted on Mon, 29 Jun 2026 17:26:05 +0000 by Duxie
Efficient Sorting, Searching, and Algorithm Design Patterns in JavaScript
Sorting & Searching Fundamentals
Sorting rearranges a array into ascending or descending order. Searching finds the index of a given element. JavaScript provides sort() for sorting and indexOf() for searching, but understanding underlying algorithms is essential for performance tuning and problem-solving.
Bubble Sort
Array.prototype.bubbleS ...
Posted on Sun, 28 Jun 2026 17:00:01 +0000 by josborne
Finding the Longest Palindromic Substring: Three Algorithmic Approaches
Given a string s, the objective is to locate and return longest substring that reads the same forwards and backwards.
Examples
Input: s = "babad"
Output: "bab"
Note: "aba" is also a valid answer.
Input: s = "cbbd"
Output: "bb"
Input: s = "a"
Output: "a"
Input: s = "a ...
Posted on Sat, 27 Jun 2026 17:42:13 +0000 by Sul
Solving the Minimum Path Sum Problem with Dynamic Programming
Given a m x n grid filled with non-negative numbers, find a path from the top-left corner to the bottom-right corner wich minimizes the sum of all numbers along its path. You can only move either down or right at any point in time.
Approach: Dynamic Programming
This problem is a classic example of dynamic porgramming. The key is to build a solu ...
Posted on Fri, 26 Jun 2026 17:06:09 +0000 by soulmedia
Solving LeetCode Problems Using Greedy Strategies
1648. Sell Diminishing-Valued Colored Balls
The objective is to maximize profit when selling balls whose values decrease by 1 after each sale. The optimal approach is a greedy strategy where we always sell the currently most valuable balls available.
By sorting the inventory in descending order, we can visualize the stock as columns. We process ...
Posted on Fri, 26 Jun 2026 16:49:48 +0000 by keystroke