結果

問題 No.2618 除霊
ユーザー ニックネームニックネーム
提出日時 2024-01-26 23:04:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 571 bytes
コンパイル時間 519 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 75,864 KB
最終ジャッジ日時 2024-01-26 23:05:26
合計ジャッジ時間 65,568 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,112 KB
testcase_01 AC 28 ms
10,112 KB
testcase_02 AC 27 ms
10,112 KB
testcase_03 AC 28 ms
10,112 KB
testcase_04 AC 41 ms
10,112 KB
testcase_05 AC 28 ms
10,112 KB
testcase_06 AC 1,571 ms
51,288 KB
testcase_07 AC 1,598 ms
51,088 KB
testcase_08 AC 1,793 ms
59,204 KB
testcase_09 AC 1,862 ms
61,580 KB
testcase_10 AC 1,964 ms
75,132 KB
testcase_11 AC 1,407 ms
50,624 KB
testcase_12 AC 1,754 ms
59,096 KB
testcase_13 AC 1,562 ms
47,488 KB
testcase_14 AC 1,769 ms
75,568 KB
testcase_15 AC 1,245 ms
46,976 KB
testcase_16 AC 1,289 ms
47,616 KB
testcase_17 AC 1,581 ms
60,836 KB
testcase_18 AC 1,648 ms
75,732 KB
testcase_19 AC 1,339 ms
49,020 KB
testcase_20 AC 1,262 ms
47,360 KB
testcase_21 AC 1,487 ms
58,876 KB
testcase_22 AC 1,647 ms
70,296 KB
testcase_23 AC 1,492 ms
48,896 KB
testcase_24 AC 1,484 ms
48,384 KB
testcase_25 AC 1,751 ms
61,304 KB
testcase_26 AC 1,735 ms
75,556 KB
testcase_27 AC 1,510 ms
48,256 KB
testcase_28 AC 1,549 ms
48,256 KB
testcase_29 AC 1,736 ms
60,828 KB
testcase_30 AC 1,917 ms
75,864 KB
testcase_31 AC 1,824 ms
59,344 KB
testcase_32 AC 1,380 ms
46,976 KB
testcase_33 AC 1,501 ms
50,652 KB
testcase_34 AC 1,521 ms
49,884 KB
testcase_35 AC 1,600 ms
51,952 KB
testcase_36 AC 1,705 ms
58,188 KB
testcase_37 AC 1,717 ms
59,136 KB
testcase_38 AC 1,815 ms
61,248 KB
testcase_39 AC 1,896 ms
62,688 KB
testcase_40 AC 1,900 ms
63,600 KB
testcase_41 AC 1,962 ms
74,128 KB
testcase_42 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
adj = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = map(int,input().split())
    adj[a-1].append(b-1); adj[b-1].append(a-1)
m = int(input())
a = {v-1 for v in map(int,input().split())}
c = [0]*n; d = [0]*n
for p in range(n):
    c[p] = p in a
    for v in adj[p]: c[p] += v in a
for p in range(n):
    if p in a:
        for v in adj[p]: d[p] += c[v]==1
s = sum(c[p]>0 for p in range(n))
for p in range(n):
    t = s-(c[p]>0)
    for v in adj[p]:
        if c[v]: t -= c[v]-(p in a)-(v in a)==0
        if v in a: t -= d[v]-(c[p]==1)
    print(t)
0