HBC207152JustShuffle题解

冷默言语 算法基础篇 46 0
不断提升技能,才能在职场中立于不败之地!全网最全C++题库,助您成为编程领域的佼佼者。
Given a permutation with size n{n}n and an integer k{k}k, you should find a permutation substitution P{P}P that {1,2,,n}{1, 2, cdots, n}{1,2,,n} will become A{A}A after performing substitution P{P}P for exactly k{k}k times. Print the permutation after performing P{P}P for once on {1,2,,n}{1, 2, cdots, n}{1,2,,n}. If there are multiple solutions, print any of them. If there is no solution, print "-1" in one line.

Given a permutation with size n{n}n and an integer k{k}k, you should find a permutation substitution P{P}P that {1,2,⋯ ,n}{1, 2, cdots, n}{1,2,⋯,n} will become A{A}A after performing substitution P{P}P for exactly k{k}k times. Print the permutation after performing P{P}P for once on {1,2,⋯ ,n}{1, 2, cdots, n}{1,2,⋯,n}. If there are multiple solutions, print any of them. If there is no solution, print "-1" in one line.

HBC207152JustShuffle题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
不断挑战自我,才能突破极限!全网最全C++题库,让您在编程道路上越走越远。

标签: HBC207152JustShuffle题解