Graph Algorithms for Island Problems in Go

Water Flow Simulation Siumlate water flow using two visited matriecs for tracking. Depth-First Search Implementation package main import "fmt" var dirs = [][]int{{1, 0}, {-1, 0}, {0, 1}, {0, -1}} func main() { var rows, cols int fmt.Scanln(&rows, &cols) grid := make([][]int, rows) vis1 := make([][]bool, ...

Posted on Thu, 09 Jul 2026 16:35:05 +0000 by Pryach

Algorithmic Analysis and Implementations for Contest 883 Division 3

Problem A: Rope Cutting Condition The task requires determining how many ropes must be severed based on their attachment points. Each rope connects a nail at height a to a branch at height b. A cut is mandatory whenever the nail is positioned strictly higher than the branch. The algorithm iterates through all given pairs, evaluates this inequal ...

Posted on Sat, 04 Jul 2026 17:59:37 +0000 by nmohamm

Dijkstra Algorithm Implementation Guide

Dijkstra Algortihm: O(n²) Approach Dijkstra's algorithm solves the single-source shortest path problem for graphs with non-negative edge weights. It efficiently computes the minimum distance from a starting vertex to all other vertices using a greedy approach. Algorithm Overview Initialization: Set the source distance to 0 and all other vertic ...

Posted on Tue, 26 May 2026 18:58:39 +0000 by benyamin

Link-Cut Trees: Dynamic Tree Data Structures

Link-Cut Trees (LCT) represent an advanced data structure specifically designed to handle dynamic tree problems efficient. By utilizing prefered path decomposition and Splay trees, LCT maintains and manipulates tree structures with logarithmic amortized time complexity for most operations. Core Concepts Preferred Path Decomposition For a given ...

Posted on Mon, 18 May 2026 07:15:33 +0000 by ridiculous

NOIP 2013 Day 2 Algorithmic Problem Solutions

Wireless Network Coverage Optimization A city grid consists of 129 east-west streets and 129 north-south streets, forming intersections at integer coordinates (x, y) where 0 ≤ x, y ≤ 128. Some intersections host public venues, each with a known count of facilities. A single wireless transmitter must be placed such that its coverage area — an ax ...

Posted on Sun, 17 May 2026 20:09:04 +0000 by pod2oo5

Topological Sorting Algorithms and Applications in Directed Acyclic Graphs

Directed Acyclic Graphs (DAG)A Directed Acyclic Graph (DAG) is a directed graph containing no cycles. If a directed graph contains a cycle, no topological ordering exists. For a valid DAG, multiple valid topological orderings may be possible.For any vertex in a directed graph, the count of incoming edges is called in-degree, and the count of ou ...

Posted on Mon, 11 May 2026 04:32:52 +0000 by Bee