TPORT - Teleport

no tags 

Little Aron has to visit the planets of one system. Imagine that the planets are ordered in line and labeled with the numbers 1, ..., n.

Aron has n-1 teleports labeled with 1, 2, ..., n-1. The teleport labeled with t could transmit only once, one human from a planet labeled with m to the planets with label m+t or m-t, if such planet exists. Using a space-stop Aron could go to the planet labeled with k, i.e. he starts his journey from a planet with a label k. For the given n and k you have to find the best way Aron can use the teleports in order to visit as many different planets of the system, as possible.


First line containts two integers, n and k (1 <= k <= n <= 1 000 000).


Output should contain indices t, of the teleports that Aron used, in the order in which he used them. Moreover you have to output t if he used the teleport to jump from a planet with the smaller number to a planet with a higher, and -t if he jumped from a planet with a higher number to a planet with a smaller number.

If there are several solutions with the same number of teleports, you can output any one of them.



6 2


4 -5 3 -1 2

NOTE - A simpler version of this task appeared on ITI 2012, Shumen.

hide comments
Dominik Gleich: 2013-01-16 17:06:06

If we said that k <= n we haven't said anything false, it's still true. And about the judge, you have nothing to worry about, it will grade the submissions as it should, accepting every optimal solution with valid steps.

Mostafa 36a2: 2013-01-16 13:58:31

you said :
(1 <= k <= n <= 1 000 000)
but k can't be equal to n...
also .. how can the judge consider AC if there is many solutions , have you write all the possibilities of your cases ?

Added by:Dominik Gleich
Time limit:0.200s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Authors: Mislav Balunović, Dominik Gleich