Graph Theory and Union-Find Data Structure Applications in Island Problems

Maximum Island Area Problem Given a matrix of 1's (land) and 0's (water), calculate the maximum island area. Islands consist of adjacent land cells connected horizontally or vertically. Input: 4 5 1 1 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 1 1 Output: 4 The solution uses DFS or BFS to traverse each island component and count its area. Python Impleme ...

Posted on Sat, 19 Sep 2026 16:43:05 +0000 by nitram

AtCoder Beginner Contest 012 - Problem Solutions

A - Swapping Two Integers Read two integers, swap their values, and output them on separate lines. B - Time Conversion Given N seconds where 0 ≤ N < 86400, convert it to 24-hour time format hh:mm:ss. The conversion formula using modular arithmetic: [N \equiv a_0 \times 3600 + a_1 \times 60 + a_2 \times 1 \pmod{86400}] Calculate hours, minute ...

Posted on Sat, 19 Sep 2026 16:13:54 +0000 by Ryokotsusai

RoboCom 2023 Provincial Competition Solutions and Analysis

Problem 1: Asian Games Medal Ranking #include <bits/stdc++.h> using namespace std; int main() { int entries; cin >> entries; vector<vector<int>> medalCounts(2, vector<int>(4, 0)); for (int i = 0; i < entries; i++) { int country, position; cin >> country >> p ...

Posted on Tue, 08 Sep 2026 16:35:19 +0000 by lucilue2003

Techniques for Solving Problems Based on Partial Order Relations

Many computational problems require determining answers based on partial order relationships between elements. When only the relative ordering matters, we can employ specialized enumeration strategies to sidestep complex case-by-case analysis. The main approaches include: Comparison Operators (): Process elements sequentially from smallest to ...

Posted on Sat, 05 Sep 2026 16:26:53 +0000 by OldWolf

NOIP 2008 Contest Solutions: Algorithm Analysis and Implementation

Lucky Word Problem A student with limited vocabulary discovered an interesting method for selecting correct answers in English multiple-choice questions. This approach has proven effective through experimentation. The technique involves analyzing character frequencies within a word. Let's define max_freq as the highest occurrence of any letter ...

Posted on Mon, 31 Aug 2026 16:11:40 +0000 by fpbaum

Solving the Pushing Boxes Problem with Single Priority Queue BFS

The UVA589 problem requires finding the optimal path to push a box to a target location. The optimization criteria have two levels: primarily minimizing the number of pushes, and secondarily minimizing the total number of moves when push counts are equal. Key Problem Constraints The primary objective is to minimize push operations, not walki ...

Posted on Mon, 24 Aug 2026 16:45:15 +0000 by seodevhead

Tree Coverage Dynamic Programming Optimization

Tree Coverage DP Model The tree coverage dynamic programming model addresses optimization problems where nodes are selected on a tree structure. Each chosen node can cover all nodes within a specified distance, with the goal of solving various optimization tasks (counting problems are not applicable). State Definition and Transition Let f[i][j] ...

Posted on Mon, 24 Aug 2026 16:37:35 +0000 by muralimohan001

Algorithm Solutions for Programming Contest Problems

Calendar Date Calculation This problem involves calculating the day of the week for a given date using a simplified calendar system where each month has 30 days. The solution processes date comparisons and computes day differences with modulo operations. #include <iostream> #include <unordered_map> using namespace std; int main() ...

Posted on Mon, 24 Aug 2026 16:00:59 +0000 by smnovick

Essential Algorithm Templates for Competitive Programming

Sorting Algorithms Quick Sort (Manual Implementation) #include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 100010; ll arr[MAXN]; int n; void quickPartition(int left, int right) { if (left >= right) return; int pivotIdx = (left + right) / 2; ll pivotVal = arr[pivotIdx]; int i = left ...

Posted on Sun, 09 Aug 2026 16:16:01 +0000 by godyn

Heavy-Light Decomposition for Tree Data Management

Introduction Heavy-light decomposition (HLD) is a sophisticated algorithmic technique used to partition tree structures into linear sequences, enabling efficient query and update operations. This method is particularly effective for handling subtree and path queries on trees. Core Definitions Heavy Child: For any node, its heavy child is the c ...

Posted on Tue, 04 Aug 2026 16:56:15 +0000 by cemeteryridge