HBC24091小宝算数[USACO 2017 Dec B]The Bovine Shuffle题解 (farmerjohn)

你曾走过我的故事 算法基础篇 39 0
全网最全C++题库,助您快速提升编程技能!题库丰富多样,涵盖各个领域,让您在练习中不断成长!
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张图片-东莞河马信息技术
(图片来源网络,侵删)
不断学习,不断挑战,才能在编程领域中脱颖而出!全网最全C++题库,助您成为编程高手!

标签: HBC24091小宝算数[USACO 2017 Dec B]The Bovine Shuffle题解