好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

CodeforcesRound#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(a k+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 

查看更多关于CodeforcesRound#275(Div.2)C的详细内容...

  阅读:32次