Codeforces Round #580 (Div. 2)——Almost Equal

You are given integer nn. You have to arrange numbers from 11 to 2n2n, using each of them exactly once, on the circle, so that the following condition would be satisfied:

For every nn consecutive numbers on the circle write their sum on the blackboard. Then any two of written on the blackboard 2n2n numbers differ not more than by 11.

For example, choose n=3n=3. On the left you can see an example of a valid arrangement: 1+4+5=101+4+5=10, 4+5+2=114+5+2=11, 5+2+3=105+2+3=10, 2+3+6=112+3+6=11, 3+6+1=103+6+1=10, 6+1+4=116+1+4=11, any two numbers differ by at most 11. On the right you can see an invalid arrangement: for example, 5+1+6=125+1+6=12, and 3+2+4=93+2+4=9, 99 and 1212 differ more than by 11.

Input

The first and the only line contain one integer nn (1≤n≤1051≤n≤105).

Output

If there is no solution, output "NO" in the first line.

If there is a solution, output "YES" in the first line. In the second line output 2n2n numbers — numbers from 11 to 2n2n in the order they will stay in the circle. Each number should appear only once. If there are several solutions, you can output any of them.

Examples

input

Copy

3

output

Copy

YES
1 4 5 2 3 6 

input

Copy

4

output

Copy

NO

Note

Example from the statement is shown for the first example.

It can be proved that there is no solution in the second example.

题目链接http://codeforces.com/contest/1206/problem/C

题意:找出一个2*n的环,从任意一个位置开始,从当前位置顺时针相加n个数,这n个数的和与任意位置顺时针相加n个数的和相差不超过1

思路:可以看出1的对角是2,3的对角是4............x的对角是x+1,所以x与x+1成一对(x为奇数)

           写出n=5的情况,1 4 5 8 9 2 3 6 7 10  可以发现规律是奇偶循环

           环的前n个数中需要且只需要选对数中的其中一个来放

           前n个数中从小到大,奇偶循环即可,后n个数放入他们的对数

           n为偶数的情况无答案

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int M=2e5+10;
int n;
int A[M];
int main()
{
    scanf("%d",&n);
    if(n%2==0)
    {
        printf("NO\n");
        return 0;
    }
    for(int i=0,judge=0,cut=0;i<n;i++,judge++)
    {
        judge%=2;
        if(judge==0)
        {
            A[i]=++cut;
            A[i+n]=++cut;
        }
        else
        {
            A[i+n]=++cut;
            A[i]=++cut;
        }
    }
    printf("YES\n");
    for(int i=0;i<2*n;i++)
        printf("%d ",A[i]);
    printf("\n");
}

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值