codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1205A.md (1637B)


      1 Source: https://codeforces.com/problemset/problem/1205/A
      2 
      3 A. Almost Equal
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 You are given integer $n$. You have to arrange numbers from $1$ to $2n$, using each of them exactly once, on the circle, so that the following condition would be satisfied:
     22 
     23 For every $n$ consecutive numbers on the circle write their sum on the blackboard. Then any two of written on the blackboard $2n$ numbers differ not more than by $1$.
     24 
     25 For example, choose $n = 3$. On the left you can see an example of a valid arrangement: $1 + 4 + 5 = 10$, $4 + 5 + 2 = 11$, $5 + 2 + 3 = 10$, $2 + 3 + 6 = 11$, $3 + 6 + 1 = 10$, $6 + 1 + 4 = 11$, any two numbers differ by at most $1$. On the right you can see an invalid arrangement: for example, $5 + 1 + 6 = 12$, and $3 + 2 + 4 = 9$, $9$ and $12$ differ more than by $1$.
     26 
     27  ![](https://espresso.codeforces.com/db52a90a44b2b75ea50560d9090f27ae9352f85b.png)
     28 
     29 Input
     30 
     31 The first and the only line contain one integer $n$ ($1 \le n \le 10^5$).
     32 
     33 Output
     34 
     35 If there is no solution, output "NO" in the first line.
     36 
     37 If there is a solution, output "YES" in the first line. In the second line output $2n$ numbers — numbers from $1$ to $2n$ 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.
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 3
     45 ```
     46 
     47 Output
     48 
     49 ```
     50 YES
     51 1 4 5 2 3 6
     52 ```
     53 
     54 Input
     55 
     56 ```
     57 4
     58 ```
     59 
     60 Output
     61 
     62 ```
     63 NO
     64 ```
     65 
     66 Note
     67 
     68 Example from the statement is shown for the first example.
     69 
     70 It can be proved that there is no solution in the second example.