#P11077. 「FSLOI Round I」石子

    ID: 10413 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>博弈论洛谷原创O2优化洛谷月赛Ad-hoc

「FSLOI Round I」石子

Description

Frank and Louis are playing a game with nn piles of stones, where the ii-th pile has aia_i stones. Denote the average of sequence a1,a2,,ana_1,a_2,\dots,a_n as xx.

Before the game starts, a positive integer not greater than xx is given. Frank and Louis take turns making the following moves with Frank going first:

  • Choose the ii-th and the jj-th piles of stones (ij)(i \neq j) satisfying ai<x<aj.a_i<x<a_j.

  • Take out kk stones from the jj-th pile and put them into the ii-th pile of stones.

The player who is unable to make a move loses.

Determine who will win if both players play optimally.

Input Format

Each test contains multiple test cases.

The first line of the input contains a single integer TT, the number of test cases. The description of test cases follows.

The first line of each test case contains two integers nn and kk.

The second line of each test case contains nn integers: a1,a2,,ana_1,a_2,\dots,a_n.

Output Format

For each test case, output F if Frank wins, L if Louis wins, and Draw if the game will never end.

1
5 2
1 5 7 9 13
L
2
6 3
4 7 5 3 1 16
7 2
2 6 4 8 12 4 6

Draw
L

Hint

Example Explanation

In the first example, aa is initially {1,5,7,9,13}\{1,5,7,9,13\}, and the average value xx of the sequence aa is 77.

One possible game process follows:

  1. Frank chooses i=1,j=5i=1,j=5, and aa becomes {3,5,7,9,11}\{3,5,7,9,11\}.

  2. Louis chooses i=1,j=4i=1,j=4, and aa becomes {5,5,7,7,11}\{5,5,7,7,11\}.

  3. Frank chooses i=2,j=5i=2,j=5, and aa becomes {5,7,7,7,9}\{5,7,7,7,9\}.

  4. Louis chooses i=1,j=5i=1,j=5, and aa becomes {7,7,7,7,7}\{7,7,7,7,7\}.

  5. Frank is unable to make a move, so Louis wins.

Constraints

Subtasks are used in this problem.

For all tests, it is guaranteed that:

  • 1T101 \le T \le 10
  • 1n2×1051 \le n \le 2 \times 10^5
  • 0ai1090 \le a_i \le 10^9
  • 1kx1 \le k \le x
  • xx is an integer.
Subtask Id Score Special Property
11 55 AA
22 1010 k=1k=1
33 1515 n5,T=1n \le 5, T=1
44 2525 n1000n \le 1000
55 4545 -

Special Property A: a1=a2==ana_1=a_2=\dots=a_n.