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, hi. The ith 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

2N106

0XN

Subtask 1 [15%]

2N15

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 hi for the ith alpaca (0hi109). If there are multiple solutions, output any.

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

Sample Input 1

Copy
6 4

Sample Output 1

Copy
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

Copy
2 1

Sample Output 2

Copy
-1

Comments


  • 0
    pargatsingh  commented 5 days ago
    Hint
    • The happiness index doesn't have to be unique per alpaca so feel free to reuse values for simplicity
    • Try drawing out a few examples with odd/even N with odd/even X and see what pattern you notice.

  • 3
    PenguinPush  commented on April 26, 2024, 5:18 p.m.

    i love an animal contest