Lara Croft
Time Limit: 1 Second Memory Limit: 32768 KB
Lara Croft Tomb Raider is my favourite game. Lara Croft is a brave girl who loves exploration. One time she was be trapped in a place where the only exit was locked.
The lock was special: it was surrounded by a circle of n number, A1,A2,...,An. Initally, there were two sliding square on the number, each time, you can only move either of the two squares around the circle in Ai grid clockwise or anticlockwise. The two square can cross each other. The door is opened when the two squares are in the same position.
Can you help lara escape the dangerous place in the least time, or our poor Lara can't open the door.
Input
The input file contains several test cases.
Each case begins with a natural number n(0<n<=100), then follow n number A1,A2,...,An in clockwise. Then the two squares' position P1,P2 ( 0<=P1<n,0<=P2<n )
The Input is ended by a 0.
Output
If the clock can be opened, you must tell Lara "open it on the nth move!" or "Lara is trapped!"
Sample Input
5 1 1 1 1 1 0 4 5 1 2 3 4 5 0 3 2 2 2 0 1 0
Sample Output
open it on the 1th move! open it on the 2th move! Lara is traped!Submit
Source: ZOJ Monthly, December 2004