結果

問題 No.1852 Divide or Reduce
ユーザー LyricalMaestro
提出日時 2024-01-07 13:17:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 410 ms / 2,000 ms
コード長 1,191 bytes
コンパイル時間 380 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 134,636 KB
最終ジャッジ日時 2024-09-27 19:22:07
合計ジャッジ時間 7,726 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

## https://yukicoder.me/problems/no/1852

def solve(N, A):
    A.sort()
    if A[0] == 1:
        ans = 0
        for i in range(1, N):
            if A[i] % 2 == 0:
                ans ^= 1
    else:
        odds = 0
        evens = 0
        for i in range(N):
            if A[i] % 2 == 0:
                evens += 1
            else:
                odds += 1
        if evens % 2 == 1:
            ans = 1
        elif odds % 2 == 1:
            ans = 0
        else:
            ans = 0
            a = 0
            if A[0] % 2 == 1:
                a = 0 # 偶数回Yができる
            else:
                a = 1 # 奇数回Yができる
            for i in range(1, N):
                b = A[i] - (A[0] - 1)
                if b % 2 == 0:
                    ans ^= 1
            if a == 1:
                ans ^= 1

    if ans == 1:
        return "First"
    else:
        return "Second"
            

def main():
    T = int(input())
    answers = []
    for _ in range(T):
        N = int(input())
        A = list(map(int, input().split()))
        answers.append(solve(N, A))

    for answer in answers:
        print(answer)




if __name__ == "__main__":
    main()
0