您好,欢迎访问一九零五行业门户网

Codeforces Round #275 (Div. 2) C

题目链接:codeforces round #275 (div. 2) c - diverse permutation
题意:一串排列1~n。求一个序列其中相邻两项差的绝对值的个数(指绝对值不同的个数)为k个。求序列、
思路:1~k+1。构造序列前段,之后直接输出剩下的数。前面的构造可以根据,两项差的绝对值为1~k构造。
ac代码:
#include #include int ans[200010];bool vis[100010];int n,mark;int iabs(int a){ if(ak+1) temp=ans[i-1]-cnt; else if(vis[temp]) temp=ans[i-1]-cnt; ans[i]=temp; vis[temp]=true; } for(i=k+1; i

其它类似信息

推荐信息