結果

問題 No.1507 Road Blocked
ユーザー convexineqconvexineq
提出日時 2021-05-14 22:39:24
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 302 ms / 2,000 ms
コード長 558 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 86,736 KB
実行使用メモリ 97,352 KB
最終ジャッジ日時 2023-07-25 08:01:10
合計ジャッジ時間 10,996 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,292 KB
testcase_01 AC 73 ms
71,296 KB
testcase_02 AC 76 ms
71,440 KB
testcase_03 AC 188 ms
96,992 KB
testcase_04 AC 284 ms
96,764 KB
testcase_05 AC 302 ms
97,024 KB
testcase_06 AC 275 ms
97,012 KB
testcase_07 AC 286 ms
97,328 KB
testcase_08 AC 271 ms
96,868 KB
testcase_09 AC 285 ms
97,192 KB
testcase_10 AC 283 ms
97,024 KB
testcase_11 AC 285 ms
97,084 KB
testcase_12 AC 277 ms
97,004 KB
testcase_13 AC 281 ms
97,080 KB
testcase_14 AC 281 ms
96,804 KB
testcase_15 AC 267 ms
96,972 KB
testcase_16 AC 281 ms
96,768 KB
testcase_17 AC 284 ms
96,992 KB
testcase_18 AC 283 ms
97,080 KB
testcase_19 AC 287 ms
97,028 KB
testcase_20 AC 285 ms
96,988 KB
testcase_21 AC 285 ms
97,032 KB
testcase_22 AC 284 ms
96,988 KB
testcase_23 AC 271 ms
97,032 KB
testcase_24 AC 272 ms
96,864 KB
testcase_25 AC 277 ms
96,980 KB
testcase_26 AC 279 ms
97,272 KB
testcase_27 AC 280 ms
97,352 KB
testcase_28 AC 279 ms
96,980 KB
testcase_29 AC 275 ms
97,060 KB
testcase_30 AC 291 ms
97,268 KB
testcase_31 AC 283 ms
96,788 KB
testcase_32 AC 271 ms
97,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
g = [[] for _ in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
 
order = []
st = [0]
parent = [-1]*n
while st:
    v = st.pop()
    order.append(v)
    for c in g[v]:
        if c != parent[v]:
            st.append(c)
            parent[c] = v

size = [1]*n
for i in order[::-1]:
    if i==0: break
    size[parent[i]] += size[i]
    
v = 0
for i in range(n):
    v += size[i]*(n-size[i])

MOD = 998244353
c = n*(n-1)*(n-1)//2%MOD
p = v*pow(c,MOD-2,MOD)%MOD
print((1-p)%MOD)
0