#P3334. Spoj336 EOPERA
Spoj336 EOPERA
题目描述
Given a sequence of 12 numbers consisting of 0 and the first 11 natural numbers. Suppose number 0 is in the i-th position of the sequence (positions are numbered from 0 to 11). You can swap it with the number in the j-th position if the following conditions hold:
- | i – j | = d , where k=1..3 and (d ,d ,d ,d )=(1;3;6;12)
- floor(i/d )=floor(j/d )
Your task is to find the minimum number of exchange operations required to sort the sequence in increasing order.
输入格式
输入数据由多组数据组成。
每一组数据由一行12个数构成P_{i}表示i号位置上的箱子编号。
输出格式
一个数,最少的交换次数。
2
1 10 2 3 0 5 7 4 8 6 9 11
6 4 1 0 3 5 9 7 2 10 11 8
8
9
提示
数据约定: 数据组数不超过100。 对于每一组数据,对应的答案不会“非常大”