結果

問題 No.1852 Divide or Reduce
ユーザー LyricalMaestroLyricalMaestro
提出日時 2024-01-07 13:17:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 388 ms / 2,000 ms
コード長 1,191 bytes
コンパイル時間 340 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 134,420 KB
最終ジャッジ日時 2024-01-07 13:17:29
合計ジャッジ時間 7,816 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 216 ms
77,140 KB
testcase_02 AC 204 ms
77,144 KB
testcase_03 AC 202 ms
77,004 KB
testcase_04 AC 229 ms
77,148 KB
testcase_05 AC 204 ms
77,160 KB
testcase_06 AC 219 ms
123,696 KB
testcase_07 AC 223 ms
115,656 KB
testcase_08 AC 231 ms
128,840 KB
testcase_09 AC 241 ms
114,316 KB
testcase_10 AC 221 ms
106,912 KB
testcase_11 AC 235 ms
134,040 KB
testcase_12 AC 236 ms
132,372 KB
testcase_13 AC 236 ms
133,908 KB
testcase_14 AC 255 ms
134,420 KB
testcase_15 AC 237 ms
134,044 KB
testcase_16 AC 388 ms
103,576 KB
testcase_17 AC 388 ms
102,804 KB
testcase_18 AC 385 ms
103,320 KB
testcase_19 AC 327 ms
102,952 KB
testcase_20 AC 342 ms
102,564 KB
権限があれば一括ダウンロードができます

ソースコード

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