Peanut Harvesting Problem Problem Description Traverse an R x C grid of peanut plants starting at the top-left corner and exiting at the bottom-right corner. Each cell holds a non-negative integer representing the number of peanuts available at that location. You may only move right or downward at a...
Consider processing graph updates in reverse. The state for each node represents the minimum cost required to become 'safe'. Each update modifies only a single node b_i, requiring an examination of its neighbors. A square root decomposition approach based on vertex degree allows for efficient handli...
This article covers several dynamic programming problems, including finding the maximum subarray sum, the longest increasing subsequence, the longest common subsequence, the longest palindromic substring, and finding the longest path in a Directed Acyclic Graph (DAG). Maximum Subarray Sum This probl...
Problem Overview Luogu P1509 "Finding a Girlfriend" presents a multi-constraint 0/1 knapsack problem. Given n items, each with three attributes rmb_i (money), rp_i (reputation), and time_i (time spent), the goal is to maximize the number of selected items such that the sum of rmb_i does no...
Simulation Contest 2 Solutions Current Progress: Linear DP, Knapsack Problems, Intervals Challenging Problems 1038 [NOIP2008] Paper Passing Tags High-Dimensional DP Approach The challenge lies in ensuring that the path from (1,1) to (n,m) and back from (n,m) to (1,1) do not overlap. It can be treate...
Problem A: Minimum Function Summation Given the function f(x) = min_{i∈ℕ⁺}, compute the sum Σ_{i=1}^{n} f(i) modulo 10^9+7 across multiple test cases. Constraints: n ≤ 10^16, T ≤ 10^4. Solution Approach: Analyze the frequency of each value in the sequence f(i). For a particular value x, we need to c...
Energy beads on a circcular necklace each have a head and tail marker, both positive integers. Adjacent beads satisfy that the tail of one equals the head of the next. Merging two adjacent beads with head a, tail b and head b, tail c releases energy a * b * c, producing a new bead with head a and ta...
Given a integer n, detremine the minimum number of perfect squares that sum to n. A perfect square is a integer that equals another integer multiplied by itself. For example: 1, 4, 9, and 16 are perfect squares. 3 and 11 are not. Example 1: Input: n = 12 Output: 3 Explanation: 12 = 4 + 4 + 4 Example...
Problem 1: Minimum Operations to Make Two Strings Equal Given two strings s and t, determine the minimum number of operations required to make them identical by deleting characters from either string. The approach involves identifying the longest common subsequence (LCS) between the two strings. Onc...
Problem Statement A tree with (n) nodes has two weights (a) and (b) per node, initailly set to (0). At each step, you can toggle the (b) value of at most one node. For nodes with (b = 1), their (a) values are toggled, followed by toggling thier (b) values and their parent's (b) values (if the parent...