AtCoder ABC 447 Contest Solutions
Problem D - Take ABC 2
An efficient approach involves processing the string from the end to identify and count valid "ABC" sequences.
#include <vector>
#include <string>
#include <iostream>
using namespace std;
void processString() {
string input;
cin >> input;
vector<int> posA, posB, posC;
...
Posted on Sat, 11 Jul 2026 16:17:57 +0000 by Sa177ir
Solution: QOJ-6322 / The 1st Universal Cup. Stage 12: Ōokayama - F. Forestry
Introduction
This is a challenging problem that combines segment tree merging with dynamic programming optimization. While it follows a relatively standard template, the overall difficulty level is high.
Prerequisites: Dynamic programming, tree-based DP, segmant tree with dynamic node allocation, segment tree merging.
Problem link: Click here
D ...
Posted on Fri, 10 Jul 2026 16:49:46 +0000 by Masna
Dynamic Programming Solutions for House Robber Problems: Linear, Circular, and Tree Variants
House Robber I
The classic house robber problem involves selecting houses to rob such that adjacent houses cannot both be robbed, maximizing total profit.
For each house, there are two choices: rob it or skip it. The decision at each position aims to maximize accumulated wealth.
State Defniition: wealth[i] represents the maximum money obtainabl ...
Posted on Tue, 07 Jul 2026 17:10:21 +0000 by djelica
Analysis of Selected Competitive Programming Problems
[CTS2024] The Gate of All Beings
This is a constructive problem on tree traversal. Observation of large test cases shows the answer does not exceed 3. It is posssible to traverse the entire tree with paths of length at most 3.
The answer is typically 0 or 1, except for small trees or star-shaped graphs. For small n (≤ 8), a brute-force search o ...
Posted on Mon, 06 Jul 2026 16:00:40 +0000 by rilana
Dynamic Programming Strategies for Contiguous Subarray Problems
Dynamic programming solutions for contiguous subarray challenges typically analyze sequences where each element serves as the endpoint of potential subarrays. This approach efficiently leverages overlapping subproblems and optimal substructure properties.
Maximum Subarray Sum
Finding the largest sum of any contiguous subarray uses Kadane's algo ...
Posted on Sat, 04 Jul 2026 17:03:11 +0000 by faheemhameed
Graph Orientation, Permutation Cycle LCM, Interval Partitioning, and Card Sequence Matching
Directed Edge Orientation with Out-Degree ConstraintGiven an undirected graph, determine the number of ways to orient all edges such that every vertex has an out-degree of exactly 1. The result should be modulo 998244353.For such an orientation to exist, the number of edges must exactly equal the number of vertices, i.e., m = n. Furthermore, ev ...
Posted on Wed, 01 Jul 2026 17:40:45 +0000 by hairyjim
Three LeetCode Problems: Binary Tree Split, Array Reduction, and Jump Game
Maximum Product of Splitted Binary Tree
Given a binary tree with root node, remove exactly one edge to split the tree into two separate subtrees. The goal is to maximize the product of the sums of both resulting subtrees. Return the result modulo 10^9 + 7.
Approach
The key insight is that during a depth-first search that calculates subtree sums ...
Posted on Mon, 29 Jun 2026 16:28:43 +0000 by sapoxgn
Counting Valid 2x2 Submatrices and Optimizing Zero-Prefix Products
To solve this problem, we scan every possible 2x2 submatrix in a n × m grid and check whether the four characters within it collectively contain at least one 'y', one 'o', and one 'u'. The order does not matter—only the presence of all three required characters.
The algorithm iterates over all valid top-left corners of 2x2 blocks (from row 1 to ...
Posted on Wed, 24 Jun 2026 17:58:58 +0000 by webdes03
Calculating the Maximum Path Sum in a Number Triangle
Problem Description
Given a number triangle, where each number is placed above two numbers in the row below, find the maximum possible sum of a path starting from the top and moving to adjacent numbers on the row below until the base of the triangle is reached.
For example, consider the following triangle:
7
3 8
8 1 0
2 7 4 4
4 5 2 6 ...
Posted on Sun, 21 Jun 2026 17:42:15 +0000 by PierceCoding
Probability Expectation Problem for Collecting Trading Cards
A player collects trading cards with n distinct types. Each draw yields card type i with probability pi. Duplicate cards convert to coins, where k coins can be exchanged for one missing card. The process continues until all card types are collected. Compute the expected number of draws required.
Input Format
First line: n (card types) and k (co ...
Posted on Sat, 20 Jun 2026 16:29:23 +0000 by Bootsman123