[Codeforces 482A] Diverse Permutation

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Codeforces 482A] Diverse Permutation相关的知识,希望对你有一定的参考价值。

?????????typename   bsp   perm   nbsp   name   git       .com   inline   

[????????????]

        https://codeforces.com/contest/482/problem/A

[??????]

         ??????????????????(k + 1)??????????????? ??? ?????????????????????1-k

         ??????i > k + 1,???Ai = i

         ??????????????? : O(N)

[??????]

        

#include<bits/stdc++.h>
using namespace std;

template <typename T> inline void chkmax(T &x,T y) { x = max(x,y); }
template <typename T> inline void chkmin(T &x,T y) { x = min(x,y); }
template <typename T> inline void read(T &x)
{
    T f = 1; x = 0;
    char c = getchar();
    for (; !isdigit(c); c = getchar()) if (c == ???-???) f = -f;
    for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - ???0???;
    x *= f;
}
int main()
{
        
        int n , k;
        read(n); read(k);
        printf("1");
        int value = k , now = 1;
        for (int i = 1; i <= k; i++) 
        {
                if (i & 1) now += value;
                else now -= value;
                printf(" %d",now);
                value--;        
        }
        for (int i = k + 2; i <= n; i++) printf(" %d",i);
        printf("
");
        
        return 0;
    
}

 

以上是关于[Codeforces 482A] Diverse Permutation的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces Round #486 (Div. 3) A. Diverse Team

Diverse Garland

D. Diverse Garland

A - Diverse Team

Gemini: Elastic SNARKs for Diverse Environments

CityPersons《CityPersons:A Diverse Dataset for Pedestrian Detection》