← All problemsSign in

Direction Swaps

You are given a grid of size $n \times m$, which consists only of the direction signs $U,$ $D,$ $L,$ or $R$. An operation consists of the following: - Select any two adjacent signs that are directed towards each other, and swap them. What is the maximum number of operations that you can perform? $\textbf{Note}$: Two cells are adjacent if they have a common side. ### Input - The first line of in

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start