QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 100

#5024. 【模板】双端队列

统计

给定 $n$ 个非负整数 $a_1, a_2, \cdots, a_N$。

Magic 和 Spark 两个人进行博弈,两个人轮流操作,每次每个人可以从数组的最左边或者最右边拿走一个数,最后所有拿走的数的异或和更大的人获胜。

问两人都采取最优策略,谁会获胜。先手获胜输出 First,后手获胜输出 Second,平局输出 Draw

输入格式

第一行一个正整数 $T$ 表示数据组数。

接下来 $T$ 组数据,

每组第一行一个整数 $n$,表示 $a$ 的长度; 接下来一行 $n$ 个整数 $a_1,a_2,\cdots ,a_n$,表示序列 $a$。

输出格式

对于每组数据,输出一行一个字符串表示答案。

样例数据

样例输入

3
2
3 3
2
3 5
3
4 4 4

样例输出

Draw
First
Second

子任务

对于 $100\%$ 的数据,$1 \leq T \leq 40$,$1 \le n \le 5 \times 10^4$,$0 \le a_i < 2^{31}$。

  • Subtask #1(15 points):$n≤15$。
  • Subtask #2(20 points):$n≤10^3$。
  • Subtask #3(25 points):保证每个 $a_i$ 在 $[0,2^{31}−1]$ 范围内均匀随机。
  • Subtask #4(40 points):无特殊限制。
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.