Summer_Sheep's blog

By Summer_Sheep, history, 4 years ago, In English

Giving an positive integer $$$n$$$ and another positive integer $$$d$$$ .

You need to create an array that its length is $$$2 \times n$$$ ,and it must meet these conditions:

1, All the numbers between $$$1$$$ to $$$n$$$ must exist $$$2$$$ times.

2, For the number $$$i$$$,if $$$i$$$ is odd ,then the two position of $$$i$$$'s difference value must be more than $$$d$$$.

3, For the number $$$i$$$,if $$$i$$$ is even ,then the two position of $$$i$$$'s difference value must not be more than $$$d$$$.

if it has no solution,print -1. Else,print the array you create as your answer.

It uses Special Judge ,so you can answer any array meet these conditions.

$$$1 \leq n \leq 10^6$$$. $$$1 \leq d \leq 5 \times 10^5$$$.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it