Breadth-First Search: Practical Problem-Solving Patterns
Problem 1: Dual Container Water Measurement
This classic state-space search problem involves two containers with known capacities and an infinite water supply. The goal is to achieve a specific volume in one container through a series of operations.
Problem Analysis
The key insight is representing each state by the current water volumes in both ...
Posted on Mon, 11 May 2026 00:29:39 +0000 by cleary1981
Weekly Contest 357 Solutions
Problem 2810 - Faulty Keeyboard
Simulate the keyboard behavior as described. When encuontering character 'i', reverse the current string.
class Solution {
public:
string finalString(string input) {
string result = "";
for(char c : input) {
if(c == 'i') {
reverse(result.begin(), ...
Posted on Sun, 10 May 2026 02:00:36 +0000 by stone
Strange Elevator Problem (P1135) - BFS Solution
Problem Description
A dream once led to an unusual elevator that operates differently from typical ones. Each floor has a number K_i (0 ≤ K_i ≤ N), and the elevator can move up or down by exactly K_i floors when the corresponding button is pressed. The elevator has four buttons: open, close, go up, and go down.
Given a building with N floors, e ...
Posted on Sat, 09 May 2026 02:44:26 +0000 by cmp241
Foundations of Search: Classic Problems and Algorithmic Insights
A: Chessboard Rook Placement
Given an (n \times n) board where certain positions marked # allow placement, determine the number of ways to place (k) identical, non-attacking rooks. Constraints: (k \leq n \leq 8).
Since each row can hold at most one rook, a depth-first search over rows is feasible. The state space is bounded by ((n+1)^n), at mos ...
Posted on Thu, 07 May 2026 01:45:42 +0000 by benzrf