Input: n = 9, p = 6, a[] = [7, 5, 4, 2, 9, 3], b[] = [4, 9, 6, 8, 7, 1], d[] = [98, 72, 10, 22, 17, 66]
Output: [[2, 8, 22], [3, 1, 66], [5, 6, 10]]
Explanation: Identify Tanks and Taps:
Tanks (houses with outgoing pipes but no incoming pipes): 2, 3, 5
Taps (houses with incoming pipes but no outgoing pipes): 8, 1, 6
Find Tank-Tap Paths:
2 -> 8 (Min Diameter = 22) -> [2, 8, 22]
3 -> 1 (Min Diameter = 66) -> [3, 1, 66]
5 -> 9 -> 7 -> 4 -> 6 (Min Diameter = 10) -> [5, 6, 10]
Input: n = 4, p = 2, a[] = [1, 3], b[] = [2, 4], d[] = [60, 50]
Output: [[1, 2, 60], [3, 4, 50]]
Explanation: Identify Tanks and Taps:
Tanks (houses with outgoing pipes but no incoming pipes): 1, 3
Taps (houses with incoming pipes but no outgoing pipes): 2, 4
Find Tank-Tap Paths:
1 -> 2 (Min Diameter = 60) → [1, 2, 60]
3 -> 4 (Min Diameter = 50) → [3, 4, 50]
Output[[2, 8, 22], [3, 1, 66], [5, 6, 10]]