Prabhanjan6

download Prabhanjan6

of 3

Transcript of Prabhanjan6

  • 7/25/2019 Prabhanjan6

    1/3

    PROBLEM 6 CHAKRAVYUH MARKS 200

    Suppose the Great Mahabharatahappens in Kalyug.And suppose you are

    Arjuns son Abhimanyu.You are trapped in the middle of a Chakravyuhwith your short range tank (Fig.). The outer circumference represents the

    range of the tank. You are surrounded by enemy Maharathishaving their

    own tanks. All the enemies tanks are outside inner circle. You cannot harm

    the tanks i.e. only shells can be destroyed. You can defend yourself against

    their attack by successfully targeting their shells before they reach the inner

    circumference. Once they reach the inner circumference, your tank will be

    destroyed. The range of the enemies tanks is large enough to reach you.

    FIG

    But the enemies tanks have a limited number of shells (

  • 7/25/2019 Prabhanjan6

    2/3

    time and fire shells with a fixed interval of time between them. For e.g.

    suppose tank 1 start shelling at time t=4 sec and required time for reloading

    is 5 seconds then it continue its firing at t=4, 9, 14, 19 until all its shells

    are fired. Each tank may have a different starting time and a different

    reloading time. Your tanks starting time is t=0 and reloading time 1 sec.

    No enemy tank has reloading time less then your tank. Once reloaded

    no enemy tank will wait for a moment and fire immediately. However,

    your tank may skip some firing ticks, if it is the optimal thing to do for

    its savior. e.g.: 103: i.e. at t=0 target=1, at t=1, target=nothing, t=2

    target=2.

    Your task is to save the tank as long as you can.

    NOTE: All shells are assumed to follow straight-line motion.

    Input:

    There will be a number of test cases. For each Test Case, first line contains a

    number n (

  • 7/25/2019 Prabhanjan6

    3/3

    their information is given in the input file.For e.g. the first tank given in

    input file is represented as 1, second as 2 and so on.

    If you can save yourself up to the time all enemies shells are used, you have

    saved your self forever. In that case you just write 1(infinite) as the time up

    to which you can save yourself and then give the sequence in which you

    target different tanks shells.

    While writing the sequence in which you target shells, as you have to

    fire continuously at regular interval, there may be some fires that would

    not hit any shell inside the firing range. Use 0 as the tank number for

    that case, e.g.

    At t=0, you hit shell of tank 1.

    At t=1, you hit shell of tank 2.

    At t=3, you hit shell of tank 1. etc.

    Then as you try to fire at t=2, the shell cannot hit anyone because theremay not be any shell inside the range, hence sequence is 1201

    Sample Input:

    3

    400 300 150 0 2 3

    -400 200 175 0 2 1

    100 300 120 0 2 2

    200

    100 200

    0

    Sample Output:

    Case 1:

    -1

    2313101

    PDF created with pdfFactory Pro trial version www.pdffactory.com

    http://www.pdffactory.com/http://www.pdffactory.com/