Looking up popular cow dances, Farmer John decides to teach his cows the "Bovine Shuffle". The Bovine Shuffle consists of hisNcows lining up in a row in some order, then performing successive "shuffles", each of which potentially re-orders the cows. To make it easier for his cows to locate themselves, Farmer John marks the locations for his line of cows with positions1…N, so the first cow in the lineup will be in position 1, the next in position 2, and so on, up to positionN.N). Every cow moves to its new location during the shuffle. Fortunately, all the. 's are distinct, so no two cows try to move to the same position during a shuffle.Farmer John's cows are each assigned distinct 7-digit integer ID numbers. If you are given the ordering of the cows after three shuffles, please determine their initial order.
Convinced that happy cows generate more milk, Farmer John has installed a giant disco ball in his barn and plans to teach his cows to dance! Looking up popular cow dances, Farmer John decides to teach his cows the "Bovine Shuffle". The Bovine Shuffle consists of his N cows (1≤N≤100) lining up in a row in some order, then performing successive "shuffles", each of which potentially re-orders the cows. To make it easier for his cows to locate themselves, Farmer John marks the locations for his line of cows with positions 1…N, so the first cow in the lineup will be in position 1, the next in position 2, and so on, up to position N. A shuffle is described with N numbers, a_1…a_N a 1 …a N , where a cow in position ii moves to position a_i a i during the shuffle (and so, each a_i a i is in the range 1…N). Every cow moves to its new location during the shuffle. Fortunately, all the a_i a i 's are distinct, so no two cows try to move to the same position during a shuffle. Farmer John's cows are each assigned distinct 7-digit integer ID numbers. If you are given the ordering of the cows after three shuffles, please determine their initial order.
![HBC24091小宝算数[USACO 2017 Dec B]The Bovine Shuffle题解
(farmerjohn)-第1张图片-东莞河马信息技术 HBC24091小宝算数[USACO 2017 Dec B]The Bovine Shuffle题解
(farmerjohn)-第1张图片-东莞河马信息技术](https://www.xxstcz.com/zb_users/upload/2023/11/20231109024803169946928331590.jpeg)