codeforces C. Diverse Permutation(构造)

简介:

题意:1...n 的全排列中 p1, p2, p3....pn中,找到至少有k个
|p1-p2| , |p2-p3|, ...|pn-1 - pn| 互不相同的元素! 

思路: 保证相邻的两个数的差值的绝对值为单调递减序列..... 
如果够k个了,最后将没有访问到的元素直接添加到末尾!

  View Code









本文转自 小眼儿 博客园博客,原文链接:http://www.cnblogs.com/hujunzheng/p/4049704.html,如需转载请自行联系原作者
目录
相关文章
|
8月前
|
算法
The kth great number(小根堆思想,模板题)
The kth great number(小根堆思想,模板题)
27 0
The kth great number(小根堆思想,模板题)
|
9月前
|
人工智能
POJ 2299 Ultra-QuickSort(树状数组+离散化+求逆序数)
POJ 2299 Ultra-QuickSort(树状数组+离散化+求逆序数)
|
网络架构
Codeforces Round #755 D. Guess the Permutation(交互 二分)
Codeforces Round #755 D. Guess the Permutation(交互 二分)
70 0
AtCoder Beginner Contest 223 D - Restricted Permutation(建图 思维 构造 拓扑排序)
AtCoder Beginner Contest 223 D - Restricted Permutation(建图 思维 构造 拓扑排序)
88 0
|
人工智能
CF1315 C.Restoring Permutation(构造 二分 贪心)
CF1315 C.Restoring Permutation(构造 二分 贪心)
52 0
|
人工智能
[Codeforces 1286B] Numbers on Tree | 技巧构造
Evlampiy was gifted a rooted tree. The vertices of the tree are numbered from 1 to n. Each of its vertices also has an integer ai written on it. For each vertex i, Evlampiy calculated ci — the number of vertices j in the subtree of vertex i, such that a j < a i
98 0
[Codeforces 1286B] Numbers on Tree | 技巧构造
|
人工智能 算法 C#
算法题丨Next Permutation
描述 Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.
1296 0