An Animal Contest 1 P3 - Happy Alpacas

View as PDF

Submit solution


Points: 7 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem types

Night has fallen, and N alpacas have gathered around a campfire. They sit in a circle, that is, alpaca 1 is to the right of alpaca N, alpaca 2 is to the right of alpaca 1, alpaca 3 is to the right of alpaca 2, and so on. Each alpaca is waiting to be assigned a happiness index, h_i. The i^\text{th} alpaca is happy if the sum of its happiness index and the happiness index of the alpaca to its right is even. Otherwise, it is sad. Being a diligent herdsman, you decide to assign each of the N alpacas a happiness index such that there are exactly X happy alpacas.

Constraints

2 \le N \le 10^6

0 \le X \le N

Subtask 1 [15%]

2 \le N \le 15

Subtask 2 [85%]

No additional constraints.

Input Specification

The first line contains two space-separated integers, N and X.

Output Specification

If no solution exists, output -1. Otherwise, output N space-separated integers, the happiness index h_i for the i^{th} alpaca (0 \le h_i \le 10^9). If there are multiple solutions, output any.

Note: Output must end with a newline with no trailing whitespace.

Sample Input 1

6 4

Sample Output 1

7 27 196 50 3 17

Explanation for Sample Output 1

The happy alpacas in this arrangement are alpaca 1, alpaca 3, alpaca 5, and alpaca 6. Note that this is not the only solution.

Sample Input 2

2 1

Sample Output 2

-1

Comments


  • -1
    HopefulCreator  commented on June 6, 2022, 7:33 p.m. edited

    Can anyone tell me why I'm getting an index error on batch 2 case 2? My code works fine on any test case I throw at it by hand. I'm working in python


  • -1
    asd029374p129by4valsd  commented on March 29, 2022, 2:24 p.m.

    Why does it give me WA (Presentation Error) on batch 2 case 18 specifically? i know its because of white space but i have used .rstrip() when printing so this shouldn't be happening. any help is appreciated thx


    • 1
      Spitfire720  commented on March 29, 2022, 3:18 p.m.

      I'd be more concerned about how you attempt to get the right answer at random than your whitespace.