Efficient Algorithms for Dragon Slaying, Backpack Optimization, and Geometric Problems
Dragon Slayer Pathfinding with Binary Enumeration
Coordinate scaling converts decimal start/end points to integers for grid processing. Binary enumeration efficiently searches all possible wall removal combinations.
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;
struct Barrier {
int x_start, ...
Posted on Fri, 24 Jul 2026 17:13:22 +0000 by chreez
Solutions for Codeforces Educational Round 162 Problems A to D
A. Moving Chips
A greedy approach is applicable. Chips can only move left to the nearest empty cell. Therefore, only the longest contiguous segment of 1s matters (denoted as s). The chips within this segment need to be consolidated. The minimal number of moves equals the number of 0s inside this segment.
#include <iostream>
#include <v ...
Posted on Fri, 24 Jul 2026 17:04:43 +0000 by jreed2132
Counting and Maximizing Product of Similar Substrings using Suffix Array and Disjoint Set Union
The annual "Phantom Pavilion Summer Wine Tasting Conference" features two events: tasting and a fun challenge. The tasting event awards the title of "Chief Taster," and the challenge event awards "Chief Hunter." Many wine tasters participate.
At the conference dinner, bartender Rainbow prepares n glasses of cocktai ...
Posted on Mon, 20 Jul 2026 17:12:27 +0000 by Seraph
Solutions to a Set of Algorithmic Challenges from an ACGO Ranking Contest
Six problems drawn from a competitive programming rating competition are analysed below. Every solution is accompanied by both C++ and Python implementations. Keep in mind that Python code may run slower and care should be taken with complexity constants.
Problem 1 – Output a Digit Different from the Product
Given two integers a and b, print an ...
Posted on Thu, 16 Jul 2026 16:13:10 +0000 by machiavelli1079
Solving Luogu High-Precision Arithmetic Problems with Java BigInteger
Java's standard library includes the BigInteger class, which simplifies handling arbitrary-precision inteegrs, eliminating the need to manually implement high-precision logic for basic arithmetic tasks.
P1303 A*B Problem
import java.math.BigInteger;
import java.util.Scanner;
public class MultiplyDemo {
public static void main(String[] args ...
Posted on Wed, 15 Jul 2026 17:30:08 +0000 by endlyss
Counting Identification Cards That Clear All Gates Using Interval Intersection
We have N identification cards, numbered from 1 to N, and M gates. The i-th gate can be passed by any card whose number lies in the inclusive range [L_i, R_i]. Find the number of cards that can pass through all M gates individually.
Input is given on standard input in the following format:
N M
L1 R1
L2 R2
...
LM RM
Print a single integer: the ...
Posted on Sun, 12 Jul 2026 17:26:46 +0000 by coldkill
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
Competitive Programming Solutions: Algorithmic Strategies
Problem 1: Frequency Balance Optimization
Brute force enumeration approach.
We iterate through all possible height levels from 1 to n, calculating the maximum achievable sum by counting elements that can meet the height constraint at each level.
View solution code``` #include #include #include
using namespace std;
void solve() { int size; cin & ...
Posted on Wed, 08 Jul 2026 16:42:36 +0000 by mottwsc
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
Solving the Watchcow Patrol Problem with Eulerian Circuit
Problem Statement
Farmer John has N farms (2 ≤ N ≤ 10^4) connected by M roads (1 ≤ M ≤ 5×10^4). Multiple roads between the same pair of farms are allowed.
Bassie starts patrolling from farm 1. Every road must be traversed exactly once in each direction, and the path must end back at farm 1.
Output any valid sequence of farms that satisfies the ...
Posted on Tue, 07 Jul 2026 16:41:18 +0000 by tha_mink