|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|2 초||512 MB||61||10||7||14.000%|
Cheeseburgers are serious business. They are the most delicious food on earth, but there is a lot of room for error when making a cheeseburger. Even otherwise capable cooks often mess up the order of the assembled ingredients.
The only correct order of ingredients between the buns is, of course, as following from top to bottom:
Any deviation from this order is completely unacceptable. Therefore it is sometimes necessary to reassemble a cheeseburger.
Space on an average plate and social norms are rather restrictive when it comes to operating on a cheeseburger. The only feasible operation is the bit-shuffle (burger-ineptly-transformed). The bit-shuffle separates the entire burger into four parts of contiguous ingredients a, b, c and d and arranges them in the new order c a d b. The size of each of the four parts is selectable and may be zero.
Since the burger cools rapidly we are interested in the minimum required bit-shuffles to arrive at an acceptable burger.
Each given cheeseburger consists of n unique ingredients labeled from 1 to n. The correct order is always the natural order 1 2 . . . n.
Figure B.1: Illustration of the first sample input.
Figure B.2: Illustration of the second sample input.
The input consists of:
Output the minimum number of bit-shuffles to correct the given cheeseburger.
9 3 4 7 8 9 1 2 5 6
3 1 3 2