結果

問題 No.1852 Divide or Reduce
ユーザー Mitarushi
提出日時 2022-02-24 23:16:11
言語 Nim
(2.2.0)
結果
AC  
実行時間 504 ms / 2,000 ms
コード長 1,007 bytes
コンパイル時間 4,240 ms
コンパイル使用メモリ 66,012 KB
実行使用メモリ 23,784 KB
最終ジャッジ日時 2024-07-02 14:14:19
合計ジャッジ時間 12,217 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils, sequtils

var n_sum = 0

proc solve() =
    let n = stdin.readLine.parseInt
    let a = stdin.readLine.split.map parseBiggestInt

    n_sum += n

    assert 1 <= n and n <= 200000
    assert a.mapIt(1 <= it and it <= 1000000000).foldl(a and b)

    let a_sum = a.foldl(a + b)

    if a.contains(1):
        if (a_sum - n) mod 2 == 0:
            echo "Second"
        else:
            echo "First"
    else:
        if (a_sum - (n + 1)) mod 2 == 0:
            echo "First"
        else:
            if n mod 2 == 1:
                echo "Second"
            else:
                let a_min = a.min
                if a_min mod 2 == 0:
                    echo "First"
                else:
                    echo "Second"

proc last_check() =
    try:
        let x = stdin.readLine
        assert x == ""
    except EOFError:
        return

let t = stdin.readLine.parseInt
assert 1 <= t and t <= 200000
for _ in 0..<t:
    solve()

assert 1 <= n_sum and n_sum <= 500000

last_check()
0