20240125 Construction Problem Solutions

P1734E First, analyze the second condition: rearrange it to $a_{r_1, c_1} - a_{r_1, c_2} \not\equiv a_{r_2, c_1} - a_{r_2, c_2} \pmod{n}$. Our goal is to ensure that the column-wise difference values between any two rows are distinct. We have not yet addressed conditions 1 and 3. Conddition 1 can be satisfied by taking all elements modulo $n$. ...

Posted on Mon, 14 Sep 2026 16:27:32 +0000 by Robkid

Minimum Distance to Deliver All Orders in a Tree Network

In a tree-structured neighborhood where the root represents the delivery station, a courier must visit all requested delivery nodes at least once. The goal is to compute, after each new delivery request, the shortest total distance required to deliver all orders so far—without needing to return to the root. The key insight is that traversing al ...

Posted on Thu, 03 Sep 2026 16:29:39 +0000 by Fritz.fx

Maximum Size Set with No Fixed Differences

Problem Statement Given three positive integers $n$, $x$, and $y$, we need to find the maximum size of a set $S$ satisfying: $S \subseteq {1, 2, \ldots, n}$ For any $a \in S$ and $b \in S$, $|a - b| \neq x$ and $|a - b| \neq y$ Output the maximum possible cardinality of $S$. Constraints: $1 \leq n \leq 10^9$, $1 \leq x, y \leq 22$ Observation ...

Posted on Wed, 02 Sep 2026 16:43:33 +0000 by mark bowen

Algorithmic Problem Solving: Simulations, Matrix Calculations, and Graph Traversal

Analyzing Core Algorithmic Challenges This document explores a series of computational tasks ranging from basic arithmetic simulations to complex graph theory applications. Each segment presents a unique logic puzzle requiring precise implementation. Basic Output and Division Logic The initial challenge requires generating a fixed motivational ...

Posted on Sun, 23 Aug 2026 16:35:55 +0000 by simplyi

Counting Islands: DFS and BFS Approaches for Grid Traversal Problems

Problem 1: Island Counting Approach Overview To solve the island counting problem, we need to traverse a 2D grid where 1s represent land and 0s represent water. An island consists of all connected land cells horizontally or vertically. We'll explore two traversal strategies: Depth-First Search (DFS) and Breadth-First Search (BFS). DFS Solution ...

Posted on Thu, 23 Jul 2026 16:25:52 +0000 by vin_akleh

Island Detection in Binary Matrices Using Graph Traversal

Given a rectangular binary matrix representing a geographical map where character '1' indicates landmass and '0' represents water, the computational task is to enumerate distinct islands. An island forms when land cells connect horizontally or vertically; diagonal adjacency does not constitute valid connectivity. The grid periphery is assumed t ...

Posted on Sun, 28 Jun 2026 17:16:35 +0000 by wdsmith

Minimizing Camera Placement on a Binary Tree Using Greedy DFS

Given a binary tree, we need to install cameras on its nodes. Each camera can monitor its parent, itself, and its immediate children. The goal is to determine the minimum number of cameras reuqired to cover the entire tree. Problem Constraints Number of nodes ranges from 1 to 1000. Node values are irrelevant (typically 0). Core Strategy The o ...

Posted on Fri, 05 Jun 2026 17:26:40 +0000 by buroy

Programming Contest Solutions and Algorithm Explanations

A. Programming Contest This problem is a straightforward implementation task. The idea is to count the number of valid years betweeen two given years, excluding specific invalid years provided in the input. void solve() { int n, m; std::cin >> n; std::vector<int> invalidYearFlag(10000, 0); // Assuming a safe upper bound ...

Posted on Mon, 01 Jun 2026 17:35:16 +0000 by czs

Solving the 0/1 Knapsack: From Brute-Force Recursion to Memoization and Dynamic Programming

Problem Overview: The 0/1 Knapsack Given a maximum capacity (or time limit) W and N distinct items, where each item has a weight (or time cost) and a value, the objective is to maximize the total value of selected items without exceeding the given capacity. Each item can be chosen at most once. Constraints Maximum Capacity W: 1 ≤ W ≤ 1000 Numb ...

Posted on Mon, 18 May 2026 13:23:16 +0000 by VDarkAzN

Determining Feasibility of Safe Aircraft Landing Sequence with Single Runway

Problem Description N aircraft are preparing to land at an airport with only one runway. The i-th aircraft arrives above the airport at time Ti and has enough remaining fuel to continue circling for Di units of time. This means it can begin landing at the earleist at time Ti, and at the latest at time Ti + Di. The landing process itself require ...

Posted on Sun, 17 May 2026 06:05:57 +0000 by inkfish