Data Structures & AlgorithmsVery hardCodeforces Div 2 · ICPC regional
2 × 3 sliding puzzle with tiles 1 to 5 and one blank (shown as _). Current board: 2 4 3 / 1 5 _. Goal board: 1 2 3 / 4 5 _. A move slides a tile that is orthogonally adjacent to the blank into the blank. What is the minimum number of moves to reach the goal?
- A. 3
- B. 6
- C. 4
- D. 10
Correct answer: B. 6
A BFS over all 360 reachable boards from the goal gives 6. Counting misplaced tiles or summing Manhattan distances are lower-bound heuristics, not the exact answer.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- Undirected simple graph on vertices A, B, C, D, E, F, G with edges A–B (1), A–E (1), A–F (1), C–E (1), D–E (1), D–G (1), E–F (1), F–G (1)…
- Distinct keys [25, 10, 8, 14, 19] are inserted, in the order given by the sequence [19, 8, 14, 10, 25], into an empty binary search tree…
- Undirected weighted graph on vertices A, B, C, D, E with edges A–B (3), A–C (3), A–D (1), B–E (1), C–D (2), C–E (3). How many distinct…
- Distinct keys [3, 21, 7, 19, 24] are inserted, in the order given by the sequence [7, 21, 19, 24, 3], into an empty binary search tree…
- Connected undirected weighted graph on vertices A, B, C, D with edges A–B (3), A–C (1), A–D (4), B–C (1), B–D (2), C–D (6). Among all…
- Array A = [2, 24, 11, 16, 9, 22, 23, 10, 19]. How many index pairs i < j satisfy (A[i] XOR A[j]) < 25? (A trie with subtree counts answers…