codeforces-scrape

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

359B.md (1587B)


      1 Source: https://codeforces.com/problemset/problem/359/B
      2 
      3 B. Permutation
      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 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 A permutation *p* is an ordered group of numbers *p*1,   *p*2,   ...,   *p**n*, consisting of *n* distinct positive integers, each is no more than *n*. We'll define number *n* as the length of permutation *p*1,   *p*2,   ...,   *p**n*.
     22 
     23 Simon has a positive integer *n* and a non-negative integer *k*, such that 2*k* ≤ *n*. Help him find permutation *a* of length 2*n*, such that it meets this equation: ![](https://espresso.codeforces.com/b54693338584d5268d5ec3ab8c4f8e90b87dea39.png).
     24 
     25 Input
     26 
     27 The first line contains two integers *n* and *k* (1 ≤ *n* ≤ 50000, 0 ≤ 2*k* ≤ *n*).
     28 
     29 Output
     30 
     31 Print 2*n* integers *a*1, *a*2, ..., *a*2*n* — the required permutation *a*. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them.
     32 
     33 Examples
     34 
     35 Input
     36 
     37 ```
     38 1 0
     39 ```
     40 
     41 Output
     42 
     43 ```
     44 1 2
     45 ```
     46 
     47 Input
     48 
     49 ```
     50 2 1
     51 ```
     52 
     53 Output
     54 
     55 ```
     56 3 2 1 4
     57 ```
     58 
     59 Input
     60 
     61 ```
     62 4 0
     63 ```
     64 
     65 Output
     66 
     67 ```
     68 2 7 4 6 1 3 5 8
     69 ```
     70 
     71 Note
     72 
     73 Record |*x*| represents the absolute value of number *x*.
     74 
     75 In the first sample |1 - 2| - |1 - 2| = 0.
     76 
     77 In the second sample |3 - 2| + |1 - 4| - |3 - 2 + 1 - 4| = 1 + 3 - 2 = 2.
     78 
     79 In the third sample |2 - 7| + |4 - 6| + |1 - 3| + |5 - 8| - |2 - 7 + 4 - 6 + 1 - 3 + 5 - 8| = 12 - 12 = 0.