题意:
解法:
X的下面只要能一直保持两个X,那么顶端就一定是X。
如果X>2,可以这样构造:
如果X<2,那么X-2就不能用,得改成用X+2,那么这样构造:
其他地方用剩余的数随便填就行了。
如果X+1>n*2-1或者X-1<1则无解。
n=2的情况要特判一下,因为上面的构造方法需要用到四个数,n=2的时候只有三个数。
code:
#include <bits/stdc++.h>
#define int long long
#define PI pair<int,int>
using namespace std;
const int maxm=2e6+5;
int a[maxm];
int n,x;
void solve(){
cin>>n>>x;
if(n==2){
if(x==2){
cout<<"Yes"<<endl;
for(int i=1;i<=3;i++){
cout<<i<<endl;
}
}else{
cout<<"No"<<endl;
}
return ;
}
if(x+1>n*2-1||x-1<1){
cout<<"No"<<endl;
return ;
}
map<int,int>mark;
if(x>2){
a[n-1]=x-1;
a[n]=x;
a[n+1]=x+1;
a[n+2]=x-2;
}else{
a[n-1]=x+1;
a[n]=x;
a[n+1]=x-1;
a[n+2]=x+2;
}
for(int i=n-1;i<=n+2;i++){
mark[a[i]]=1;
}
int now=1;
for(int i=1;i<=n*2-1;i++){
if(a[i])continue;
while(mark[now])now++;
a[i]=now;
mark[now]=1;
}
cout<<"Yes"<<endl;
for(int i=1;i<=n*2-1;i++){
cout<<a[i]<<endl;
}
}
signed main(){
ios::sync_with_stdio(0);
solve();
return 0;
}