結果
| 問題 |
No.1852 Divide or Reduce
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-02-26 16:58:23 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 263 ms / 2,000 ms |
| コード長 | 1,689 bytes |
| コンパイル時間 | 1,099 ms |
| コンパイル使用メモリ | 82,816 KB |
| 実行使用メモリ | 139,616 KB |
| 最終ジャッジ日時 | 2024-07-04 13:17:40 |
| 合計ジャッジ時間 | 7,753 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 |
ソースコード
from collections import defaultdict, deque, Counter
from heapq import heapify, heappop, heappush
import math
from copy import deepcopy
from itertools import combinations, permutations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
import sys
def input():
return sys.stdin.readline().rstrip()
def getN():
return int(input())
def getNM():
return map(int, input().split())
def getList():
return list(map(int, input().split()))
def getListGraph():
return list(map(lambda x:int(x) - 1, input().split()))
def getArray(intn):
return [int(input()) for i in range(intn)]
mod = 10 ** 9 + 7
MOD = 998244353
# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')
sys.setrecursionlimit(10000000)
inf = float('inf')
eps = 10 ** (-15)
dy = [0, 1, 0, -1]
dx = [1, 0, -1, 0]
#############
# Main Code #
#############
"""
先手はX, Y両方試せる
どこかの山を1とA[i] - 1に分割したらその後はXしか行えない
A[i] - 1の総和が奇数なら後手に偶数個で渡せてXを交互に行うことで先手が勝てる
偶数の場合は操作Yを行い偶数個取り除ければ安全に渡せる
後手も同じ操作を行い先手に渡す
Yを行える回数が奇数なら先手の勝ち
"""
T = getN()
for _ in range(T):
N = getN()
A = getList()
X = 0
Y = inf
for a in A:
X += a - 1
Y = min(Y, a)
Y -= 1
# Xの操作回数が奇数なら
if X % 2 != 0:
print('First')
else:
# 偶数個引け、かつ奇数回施行できる
if N % 2 == 0 and Y % 2 != 0:
print('First')
else:
print('Second')