結果

問題 No.2841 Leaf Eater
コンテスト
ユーザー kidodesu
提出日時 2026-07-23 19:52:32
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 601 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 816 ms
コンパイル使用メモリ 95,860 KB
実行使用メモリ 126,336 KB
最終ジャッジ日時 2026-07-23 19:52:45
合計ジャッジ時間 5,690 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 4 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def main():
    n = int(input())
    P = [-1] + list(map(lambda x: int(x)-1, input().split()))
    A = [1] * n
    B = [0] * n
    for i in P[1:]:
        B[i] += 1
    S = [i for i in range(n) if not B[i]]
    while S:
        u = S.pop()
        if u == 0:
            continue
        v = P[u]
        B[v] -= 1
        if not B[v]:
            S.append(v)
        if A[u]:
            if not A[v]:
                return "First"
            A[u], A[v] = 0, 0
    if A[0] and max(A[1:]) == 0:
        return "Second"
    else:
        return "First"

for _ in range(int(input())):
    print(main())
0