传统题 1000ms 64MiB

Return of the Nim

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Problem Description

Sherlock and Watson are playing the following modified version of Nim game:

  • There are n piles of stones denoted aspiles0,piles1,...,pilesn-1, and n is a prime number;
  • Sherlock always plays first, and Watson and he move in alternating turns. During each turn, the current player must perform either of the following two kinds of moves:
    1. Choose one pile and remove k(k >0) stones from it;
    2. Remove k stones from all piles, where 1≤k≤the size of the smallest pile. This move becomes unavailable if any pile is empty.
  • Each player moves optimally, meaning they will not make a move that causes them to lose if there are still any better or winning moves.
Giving the initial situation of each game, you are required to figure out who will be the winner

Input Format


The first contains an integer, g, denoting the number of games. The 2×g subsequent lines describe each game over two lines:
1. The first line contains a prime integer,
n, denoting the number of piles.
2. The second line contains
n space-separated integers describing the respective values of piles0,piles1,...,pilesn-1.

  • 1≤g≤15
  • 2≤n≤30, where n is a prime.
  • 1≤pilesi≤105 where 0≤i≤n−1


Output Format

For each game, print the name of the winner on a new line (i.e., either “Sherlock”or “Watson”)
2
3
2 3 2
2
2 1
Sherlock
Watson

国庆训练赛

未参加
状态
已结束
规则
XCPC
题目
11
开始于
2017-10-1 20:00
结束于
2017-10-2 1:00
持续时间
5 小时
主持人
参赛人数
51