Algorithmic Solutions for Dynamic Programming and String Manipulation

Calculating Dice Roll CombinationsGiven d identical dice, each with f faces labeled from 1 to f, the objective is to determine the number of ways to achieve a specific sum target when rolling all dice. The result should be returned modulo 10^9 + 7.A recursive approach with memoization efficiently solves this by breaking the problem down into sm ...

Posted on Sun, 20 Sep 2026 16:15:08 +0000 by Floodboy

The Multiple Knapsack Problem

The Multiple Knapsack Problem Given n types of items, where type i has c_i copies, value v_i, and weight w_i. We need to select items to maximize the total value in a knapsack with maximum capacity m. Solution 1 One approach is to transform the multiple knapsack problem into a 0-1 knapsack problem. The naive method would be to split each item t ...

Posted on Thu, 17 Sep 2026 16:40:37 +0000 by jeffz2008

AGC022F Checkers: A Dynamic Programming Approach on Multi-way Trees

We examine the problem of merging \(n\) initial unit vectors \(\mathbf{e}_1,\ldots,\mathbf{e}_n\) via operations that combine two vectors \(\mathbf{u},\mathbf{v}\) into either \(2\mathbf{u} - \mathbf{v}\) or \(2\mathbf{v} - \mathbf{u}\), depending on which one "wins". Each final vector’s \(i\)-th component is of the form \((-1)^{c_i}2 ...

Posted on Tue, 15 Sep 2026 16:36:04 +0000 by cneale

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

SMU Summer 2023 Programming Contest: Solutions

This document provides solutions for problems from the SMU Summer 2023 Contest, Round 6. A. Burger Optimization This problem involves maximizing profit from selling two types of burgers with different ingredients and prices, given a limited number of buns. The strategy is to iterate through all possible counts of the first burger type, up to th ...

Posted on Sat, 12 Sep 2026 16:45:31 +0000 by ccx004

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

Dynamic Programming: Integer Break and Unique Binary Search Trees

343. Integer Break Problem Link: LeetCode 343 - Integer Break Given an integer n, break it into at least two positive integers, where the sum equals n. Return the maximum product possible from these integers. Example: Input: 2 Output: 1 Explanation: 2 = 1 + 1, 1 × 1 = 1 Apprroach This is a classic dynamic programming problem that can be solv ...

Posted on Sun, 06 Sep 2026 16:35:09 +0000 by kontesto

Dynamic Programming and Advanced Data Structures

A The problem involves matrices and their properties. The key insight is to treat four types of brackets as distinct invertible matrices. Two strings can be concatenated if their product equals the identity matrix. While this is a necessary condition, it's not sufficient. However, hashing can serve as an effective heuristic. We maintain prefix ...

Posted on Sat, 05 Sep 2026 16:36:49 +0000 by ziola

Maximum Non-Attacking Artillery Units on Terrain Map

Problem Description Commanding officers need to deploy artillery units on an N×M grid map. The map consists of N rows and M columns, with each cell being either mountainous terrain (denoted by 'H') or plain terrain (denoted by 'P'). Artillery units can only be placed on plain terrain, with a maximum of one unit per plain cell. The attack range ...

Posted on Wed, 02 Sep 2026 16:28:43 +0000 by usamaalam

Advanced Algorithmic Solutions in Competitive Programming

T1: Data Generation Analysis Problem The first problem initially appeared to be a three-dimensional partial ordering challenge, but the constraints suggested a different approach. The key insight came from examining the data generator closely, as the problem statement hinted that the generation method was crucial for solving it. Analyzing the d ...

Posted on Tue, 01 Sep 2026 16:21:01 +0000 by adeelahmad