codeforces-scrape

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

286A.md (1159B)


      1 Source: https://codeforces.com/problemset/problem/286/A
      2 
      3 A. Lucky Permutation
      4 
      5 time limit per test
      6 
      7 2 seconds
      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* of size *n* is the sequence *p*1, *p*2, ..., *p**n*, consisting of *n* distinct integers, each of them is from 1 to *n* (1 ≤ *p**i* ≤ *n*).
     22 
     23 A lucky permutation is such permutation *p*, that any integer *i* (1 ≤ *i* ≤ *n*) meets this condition *p**p**i* = *n* - *i* + 1.
     24 
     25 You have integer *n*. Find some lucky permutation *p* of size *n*.
     26 
     27 Input
     28 
     29 The first line contains integer *n* (1 ≤ *n* ≤ 105) — the required permutation size.
     30 
     31 Output
     32 
     33 Print "-1" (without the quotes) if the lucky permutation *p* of size *n* doesn't exist.
     34 
     35 Otherwise, print *n* distinct integers *p*1, *p*2, ..., *p**n* (1 ≤ *p**i* ≤ *n*) after a space — the required permutation.
     36 
     37 If there are multiple answers, you can print any of them.
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 1
     45 ```
     46 
     47 Output
     48 
     49 ```
     50 1
     51 ```
     52 
     53 Input
     54 
     55 ```
     56 2
     57 ```
     58 
     59 Output
     60 
     61 ```
     62 -1
     63 ```
     64 
     65 Input
     66 
     67 ```
     68 4
     69 ```
     70 
     71 Output
     72 
     73 ```
     74 2 4 1 3
     75 ```
     76 
     77 Input
     78 
     79 ```
     80 5
     81 ```
     82 
     83 Output
     84 
     85 ```
     86 2 5 3 1 4
     87 ```