问题 - 1205A - 代码强制 (codeforces.com)
![](https://img-blog.csdnimg.cn/img_convert/6e096599645a423eaff36d14c9e7ba9a.png)
![](https://img-blog.csdnimg.cn/img_convert/c97e70bd59c142c49785aae5aaa63388.png)
让我们将2 * n 排列成一个圈,满足任意 的两组 连续的n个数的差值不大于1
#include <iostream>
#include <bits/stdc++.h>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#define x first
#define y second
#define pb emplace_back
#define fu(i,a,b) for(int i=a;i<=b;i ++ )
#define fd(i,a,b) for(int i=a;i>=b;i -- )
#define endl '\n'
#define ms(x,y) memset(x,y,sizeof x)
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
typedef long long LL;
typedef vector<vector<LL>> VVL;
typedef vector<LL> VL;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef pair<double,int> PDI;
typedef pair<char,int> PCI;
typedef pair<string,int> PSI;
typedef pair<int,string> PIS;
typedef pair<LL,LL> PLL;
typedef __int128 i128;
typedef unsigned long long ULL;
const int N = 1e6+ 10,M = N * 4,INF = 0x3f3f3f3f ;
const int mod = 1e9;
const double eps = 1e-8;
int n,m;
inline void solve()
{
cin >> n;
if(n % 2 == 0 )
{
cout <<"NO\n";return;
}
cout << "YES\n";
// 2i +-1 将1~2*n 全部用上
fu(i,1,n)
// 前面n个数 偶数的位置小,后面n个数偶数的位置大
cout << i * 2 - (i % 2 ==0 ) <<" ";
fu(i,1,n)
cout << i * 2 - (i % 2== 1 ) << " "[i == n];
}
signed main()
{
// freopen("1.txt","w",stdout);
ios
int t=1;
// cin>>t;
int now = 1;
while(t -- )
{
// cout<<"Case ";
// cout<<"Scenario #";
// cout<< now ++ <<": ";
// cout<< now ++ <<": \n";
solve();
}
return 0;
}