
[ad_1]
A criminal has been spotted along a straight single-filed road of length $L$ at position $P$, measured from the left endpoint of the road! Two police officers arrive to the road at positions $A$ and $B$ respectively, also measured from the left endpoint of the road. The chase begins! Pursuit occurs in 1 time unit intervals, of which the following can happen in order:
-
The police officers can choose to wait, or move to the left or right of where they are by 1 unit distance.
-
The criminal can choose to wait, or move to the left or right of where he is by 1 or 2 unit distance. However, if a police officer occupies the same position as the criminal, he can only move 1 unit distance now as he needs to perform a manoeuvre to evade them!
-
The police officer captures the criminal!
What is the longest time the criminal can evade the police officers for?
Assume the following:
- $0 \leq A \leq L$
- $0 \leq B \leq L$
- $0 \leq P \leq L$
- $A \ne B \ne P$.
Seems like a classic pursuit-evasion question. However, I seem to be missing something. These are my following considerations thus far:
- Start tracking $T$, the time the criminal has evaded the police officers for so far.
- First, I will just consider $A < B$ as I can freely swap the police officer’s positions anyway.
- If the criminal is to the left or right of both police officers, i.e. $P < A$ or $P > B$ where he is not in between them, he can only run to the left or right end of the road, so I will arbitrarily just set $P$ to either be $0$ or $L$. Else, I will note that he was between the officers.
- Now, I will make the police officers travel together. This stops the criminal from evading the police officers multiple times in a row if they happen to end up on the same square. So while $B – A > 2$, I will move $B$ to the left and $A$ to the right. Of course, this takes time in itself, so I will increment $T$ for every movement they make.
- So here, if the criminal is actually at an endpoint, the solution is fairly simple. You wil simply move either $A$ to the right if the criminal is at the right endpoint ($P = L$) by $L – A – 1$ units, or move $B$ to the left if the criminal is at the left endpoint ($P = 0$) by $B – 1$ units, and catch the criminal there.
- However, if the criminal was originally between the officers, I now need to check if there is a space between the officers, and subsequently either move $A$ to the right or $B$ to the left (and also increment $T$). Then, I can say that the officers will catch the criminal in $max(A, L – B)$.
Logically this makes sense to me, but yet it is not the correct answer (solution is implemented as code and ran against test cases using judging software). Any hints or ideas?
[ad_2]