HBC17345Permutation题解

素流年 算法基础篇 87 0
挑战自我,勇攀编程高峰!全网最全C++题库,助您成为编程达人。
Chiaki has a special machine which can generate permutations. You can give any restrictions to the machine, it will generate all the permutation under the restrictions .Chiaki has generated n restrictions and the i-th of them is that the position of ai should be less than the position of bi and ci.The restrictions generated by Chiaki are somewhat special and the sequence a1,a2,...,an, b1,b2,...,bn, c1, c2, ..., cn is a permutation of 1,2,...,3n.Among all the permutations generated by the machine, Chiaki would like to find one with minimum value.

Chiaki has a special machine which can generate permutations. You can give any restrictions to the machine, it will generate all the permutation under the restrictions . Chiaki has generated n restrictions and the i-th of them is that the position of ai should be less than the position of bi and ci. The restrictions generated by Chiaki are somewhat special and the sequence a1,a2,...,an, b1,b2,...,bn, c1, c2, ..., cn is a permutation of 1,2,...,3n. Among all the permutations generated by the machine, Chiaki would like to find one with minimum value. The value of a permutation p1,p2,...,pn is sumlimits_{i=2}^{n}|p_i-p_{i-1}| i=2 ∑ n ​ ∣p i ​ −p i−1 ​ ∣.

HBC17345Permutation题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
不断学习,不断挑战,才能在编程领域中脱颖而出!全网最全C++题库,助您成为编程高手!

标签: HBC17345Permutation题解