結果

問題 No.2726 Rooted Tree Nim
ユーザー ニックネームニックネーム
提出日時 2024-04-12 22:25:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 452 bytes
コンパイル時間 144 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 69,600 KB
最終ジャッジ日時 2024-04-12 22:25:31
合計ジャッジ時間 17,399 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,752 KB
testcase_01 AC 1,654 ms
10,752 KB
testcase_02 AC 1,139 ms
30,596 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 1,162 ms
61,012 KB
testcase_06 AC 1,176 ms
61,008 KB
testcase_07 AC 1,351 ms
67,436 KB
testcase_08 AC 1,379 ms
69,600 KB
testcase_09 AC 1,075 ms
24,828 KB
testcase_10 AC 1,110 ms
24,508 KB
testcase_11 AC 1,029 ms
30,276 KB
testcase_12 AC 1,228 ms
61,712 KB
testcase_13 AC 1,093 ms
25,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

for _ in range(int(input())):
    n,k = map(int,input().split())
    adj = [[] for _ in range(n)]
    for _ in range(n-1):
        x,y = map(int,input().split())
        adj[x-1].append(y-1); adj[y-1].append(x-1)
    a = list(map(int,input().split()))
    def dfs(v,p):
        for c in adj[v]:
            if c!=p: f[c] = f[v]^1; dfs(c,v)
    f = [0]*n; dfs(0,-1); z = 0
    for u,v in zip(f,a):
        if u: z ^= v%(k+1)
    print("K" if z else "P")
0