Contest Problem Solutions: Factorization, Rays, String Construction, and Tree Partitioning
Factorization into Factorial Divisors
Given integers (n) and (m) where (1 \le m \le n!) and (n \le 20), decompose (m) into a sum of at most (n) divisors of (n!). A solution is guaranteed to exist.
Define a sequence (d_i = \frac{n!}{i!}) for (i) from 1 to (n). By iterating downwards from (i=n) to (1) and greedily subtracting the largest possible ...
Posted on Mon, 01 Jun 2026 17:41:27 +0000 by taldos
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
AtCoder ABC 069 Solutions
Problem A - 4
Question
With (n) horizontal lines and (m) vertical lines drawn on a plane, how many axis-aligned rectangles are formed that contain no interior lines?
Solution
Consider each dimension independent.
Along any straight line, (n) distinct points partition the line into (n - 1) segments. These segments serve as the edges of our rectan ...
Posted on Fri, 22 May 2026 20:05:22 +0000 by suresh1
Dynamic Programming on Increasing and Decreasing Sequences
Consider a sequence $A = (a_1, a_2, \dots, a_n)$. We want to partition $A$ into contiguous subsequences, and then arrange these subsequences to form a new sequence $f_1, f_2, \dots, f_k$. Each contiguous subsequence $f_1, \dots, f_p$ must satisfy either $f_1 \le f_2 \le \dots \le f_p$ or $f_1 \ge f_2 \ge \dots \ge f_p$. The cost associated with ...
Posted on Tue, 19 May 2026 12:41:33 +0000 by thedream
Contest Round 33 Editorial: Emphasis on Algorithmic Thinking
A. Word Rearrangement
This is a straightforward problem requiring only basic input/output handling.
w1, w2 = input().split()
print(w2)
print(w1)
B. Cooking Tangyuan
The key idea is to simulate the process of using packages to fulfill cooking rounds. Each package contributes a fixed number of tangyuan, and excess can carry over.
n, x, k = map(i ...
Posted on Sun, 17 May 2026 14:48:21 +0000 by Fjerpje
Interval Dynamic Programming: Classic Problems and Solutions
Progress: Dynamic Programming - Linear DP, Knapsack, Interval DP
Merging Palindromic Substrings
Tags: Interval DP
Foundation - Longest Palindromic Substring
Problem: Given a string (S), find the length of its longest palindromic substring.
Approach: A longer palindrome can always be constructed by adding identical characters to both ends of a s ...
Posted on Thu, 14 May 2026 05:56:34 +0000 by sb
Greedy Algorithm: Minimum Cameras to Monitor a Binary Tree
Greedy Algorithm: Minimum Cameras to Monitor a Binary Tree
Given a binary tree, we need to place cameras on nodes such that every node in the tree is monitored. A camera placed on a node monitors itself, its parenet, and its immediate children. Determine the minimum number of cameras required.
Approach
We can solve this problem using a greedy a ...
Posted on Wed, 13 May 2026 14:26:44 +0000 by TPerez
LLVM RAGreedy Register Allocator Internals: Allocation, Eviction, Splitting, and Spilling Mechanics
Core Core Data Structures
Structure
Purpose
LiveIntervals
Stores live ranges for every virtual register
LiveRegMatrix
Tracks physical-to-virtual mappings and interference
PriorityQueue
Heap-based queue ordered by Priority
VirtRegMap
Final virtual → physical assignment
EvictAdvisor
Decides whether evicting an existing allocation i ...
Posted on Wed, 13 May 2026 03:59:11 +0000 by dnice
Codeforces Round 966 (Div. 3) Solutions
A. Primary Task
Approach
The string is invalid in the following cases:
Length ≤ 2.
Does not start with "10".
The substring after "10" converts to an integer less than 2, or has leading zeros.
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
void solve() {
string s;
cin >> s;
if ...
Posted on Tue, 12 May 2026 16:38:35 +0000 by Janjan
Preliminary solutions for AtCoder Beginner Contest 064
Problem A: Check multiples of 4
Given three digits a, b, c (most significant first), form the three-digit number n = 100*a + 10*b + c. Determine whether n is divisible by 4.
int a, b, c; cin >> a >> b >> c;
int n = a * 100 + b * 10 + c;
cout << (n % 4 == 0 ? "YES" : "NO") << "\n";
Pro ...
Posted on Mon, 11 May 2026 07:02:20 +0000 by lostsoul111455