cf483C (Question suspected wrong)
Title Description
Configured with a length of n are arranged such that the set \ (\ {| p_i-p_ {i + 1} | \} \) size to be k. n <= 10 ^ 5
practice
Construction problems.
Consider \ (| P_ P_i-I +. 1 {} | = K-I. 1 + \) , so that, k + 1 can be constructed after the collection. Then the rest of the small to large order can be put in the past.
How to make \ (| p_i-p_ {i + 1} | = k-i + 1 \) it? This may be: 1, k + 1, 2 , k, 3, k-1 ...
#include<bits/stdc++.h>
using namespace std;
int n,k;
int main(){
cin>>n>>k;
int now=1;
bool d=1;
for(int i=1;i<=k+1;i++){
cout<<now<<' ';
if(d)now+=k-i+1;
else now-=k-i+1;
d=!d;
}
for(int i=k+2;i<=n;i++){
cout<<i<<' ';
}
}