Submit | All submissions | Best solutions | Back to list |
TPORT - Teleport |
Little Aron has to visit the planets of one system. Imagine that the planets are ordered in line and labeled with the numbers 1 to 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.
Input
First line contains two integers n and k (1 ≤ k ≤ n ≤ 1 000 000).
Output
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.
Example
Input:
6 2
Output:
4 -5 3 -1 2
NOTE - A simpler version of this task appeared on ITI 2012, Shumen.
Added by: | Dominik Gleich |
Date: | 2012-11-28 |
Time limit: | 0.200s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Authors: Mislav Balunović, Dominik Gleich |
hide comments
2013-01-16 17:06:06 Dominik Gleich
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. |
|
2013-01-16 13:58:31 Mostafa 36a2
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 ? |