Algorithmic Challenges: Path Optimization in Space and Travel

Interstellar PathfindingProblem StatementThere are n galaxies in the universe, each with an energy value e_i. There are m bidirectional wormholes connecting galaxies u and v. Using a wormhole from u to v consumes energy c and provides an energy gain of d (if current energy is less than c, the wormhole cannot be used). Find the minimum initial e ...

Posted on Thu, 06 Aug 2026 16:19:14 +0000 by classic

Competitive Programming Solutions: SMU Winter 2025 Round 1

Problem A: Level Progression Validation The task requires verifying the consistency of game level statistics over multiple sessions. We are given a sequence of records, each containing the total number of games played and the total levels cleared. For the records to be valid, three conditions must be met: Both total games played and total leve ...

Posted on Wed, 05 Aug 2026 16:43:39 +0000 by Timewell

Essential Algorithm Implementations in C++

Number Theory Fast Exponentiation Computes base raised to the power of exp modulo mod efficiently using binary decomposition. long long fast_power(long long base, long long exp, long long mod) { long long result = 1; base %= mod; while (exp > 0) { if (exp & 1) result = (result * base) % mod; base = (base * bas ...

Posted on Wed, 05 Aug 2026 16:13:30 +0000 by cherubrock74

Competitive Programming Solutions: Niuke Summer Multi-School Training Camp 2024

Given an integer x, construct a y < x such that gcd(x, y) = x ⊕ y (bitwise XOR). The solution is to take y = x - lowestSetBit(x). If x is a power of 2, then no solution exists. #include<iostream> #include<cmath> using namespace std; using ll = long long; void solve() { ll x; cin >> x; ll lowest_bit = x & ...

Posted on Tue, 04 Aug 2026 16:19:06 +0000 by VLE79E

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

Determining Graph Connectivity using DFS and BFS

Algorithmic Approach When handling graph problems, especially those involving large datasets, an adjacency list is often preferred over an adjacency matrix to optimize memory usage, particularly when the vertex count may exceed standard limits. To determine if an undirected graph is connected, one can traverse the structure using either Depth-F ...

Posted on Sun, 19 Jul 2026 16:48:56 +0000 by Jay87

Python Implementation of the Hungarian Algorithm

The Hungarian Algorithm is a classic approach to solve the Maximum Bipartite Matching problem. In a bipartite graph, it identifies the largest set of edges such that each vertex is connected to at most one adjacent vertex. To illustrate its operation, consider a bipartite graph with left vertices (tasks: A, B, C, D) and right vetrices (workers: ...

Posted on Mon, 13 Jul 2026 16:22:53 +0000 by MichaelHe

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

Optimizing Prisoner Allocation Using Union-Find and Binary Search

The problem involves distributing N prisoners into two separate prisons based on M pairs of conflicts. Each conflict pair is defined by two prisoner IDs and a conflict weight. The objective is to arrange the prisoners such that the maximum conflict weight among any two prisoners sharing the same prison is minimized. We need to determine this mi ...

Posted on Fri, 03 Jul 2026 16:29:09 +0000 by PHPSpirit