#P11865. Interval Game Strategy

    ID: 13966 Type: Default 1000ms 256MiB

Interval Game Strategy

Interval Game Strategy

In this problem, two players (named C and T) are given two sequences of length (n) each. The two sequences, (C) and (T), contain (2n) distinct numbers. The game is played as follows:

  1. Initially, both players know both sequences completely.
  2. Player C chooses two distinct numbers (a) and (c) from his sequence such that (a < c), and announces them to player T.
  3. Then player T chooses two distinct numbers (b) and (d) from his sequence satisfying (b < d), and announces them to player C.
  4. Next, player C picks a real number (x_c) with (a \le x_c \le c) and tells it to player T.
  5. After that, player T picks a real number (x_t) with (b \le x_t \le d) and tells it to player C.
  6. Let (x = \frac{x_c+x_t}{2}). The scores are then determined as follows: [ S_C = (x-a)(x-c), \quad S_T = (x-b)(x-d). ] Note that if (x) equals one of the endpoints of the intervals, the corresponding product is zero; otherwise the product is negative because (x) lies between the two numbers. In other words, each player wants to maximize his score (i.e. be as close to zero as possible).

The outcome is decided by comparing the two scores: the player with the higher score wins; if the scores are equal, the game ends in a draw.

Both players will adopt their optimal strategies (i.e. try to win, or if winning is impossible, force a draw). Your task is to determine the game outcome (from the point of view of player C) when both players play optimally, and to provide one valid pair of numbers (a) and (c) from C's sequence that achieves C’s optimal outcome.

An important observation is that since the score formulas satisfy (S_C=(x-a)(x-c)) and (S_T=(x-b)(x-d)) and (x) always lies within the chosen intervals, the maximum score each player may guarantee is 0 (attained when (x) equals one of the endpoints of his chosen pair). In particular, note that if player C can force the final value (x) to equal one of his endpoints while preventing T from doing the same, he will win. In our intended solution the following strategy (which depends only on the extreme values in the two sequences) is used:

Let [ C_{min} = \min C, \quad C_{max} = \max C, \quad T_{min} = \min T, \quad T_{max} = \max T. ] Then, one may prove that if (C_{max} < T_{min}) then player C can secure a win; if (C_{min} > T_{max}) then player T can force a win (i.e. C loses); otherwise, with optimal play the outcome is a draw.

When a winning or drawing strategy is available for C, a valid pair for C to announce is as follows:

  • If (C_{max} < T_{min}) (winning case): choose (a = C_{min}) and (c = C_{max}).
  • Otherwise (draw or losing case): choose the two smallest numbers in (C) (i.e. (a) equal to the smallest and (c) equal to the second smallest element of (C)).

You are given the input in the following format and you should output the game outcome and one valid pair (a) and (c) (separated by space) on the next line.

inputFormat

The first line contains an integer (n) ((n \ge 2)). The second line contains (n) space‐separated integers representing the sequence (C). The third line contains (n) space‐separated integers representing the sequence (T). It is guaranteed that all the (2n) numbers are distinct.

outputFormat

Output two lines. The first line should be one of the strings:

• “Win” if player C can guarantee a win, • “Lose” if player T can force a win, • “Draw” if the game ends in a draw with optimal play.

The second line should contain two space‐separated numbers (a) and (c) (with (a < c)) chosen from C’s sequence that yield the optimal outcome for player C.

sample

2
1 2
3 4
Win

1 2

</p>