Computing Minimum Knight Moves on a Chessboard Using BFS and DFS
Given an n × m chessboard (with 1 < n, m ≤ 400) and the starting position of a knight, determine the minimum number of moves required for the knight to reach every other square. If a square is unreachable, output -1.
Input Format
A single line containing four integers: n, m, start_x, and start_y.
Output Format
Print an n × m matrix. Each val ...
Posted on Tue, 09 Jun 2026 17:50:23 +0000 by fourteen00
Minimum Button Presses for a Strange Elevator
A building has an unusual elevator system. Each floor i (where 1 ≤ i ≤ N) has a fixed value K[i], which determines how many floors the elevator moves when the "up" or "down" button is pressed. The elveator can only move up by K[i] floors or down by K[i] floors from floor i. If the target floor would be below 1 or above N, th ...
Posted on Mon, 18 May 2026 01:53:57 +0000 by bobdabuilder