結果

問題 No.1796 木上のクーロン
ユーザー SchneeSchnee
提出日時 2021-12-25 01:16:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 945 bytes
コンパイル時間 106 ms
コンパイル使用メモリ 12,064 KB
実行使用メモリ 10,516 KB
最終ジャッジ日時 2023-10-20 04:58:45
合計ジャッジ時間 18,456 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,276 KB
testcase_01 AC 32 ms
10,276 KB
testcase_02 WA -
testcase_03 AC 30 ms
10,276 KB
testcase_04 WA -
testcase_05 AC 30 ms
10,276 KB
testcase_06 AC 30 ms
10,276 KB
testcase_07 AC 30 ms
10,276 KB
testcase_08 RE -
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#def pprint(x):
#    for i in x:
#        print(i)

n = int(input())
qs = [int(i) for i in input().split()]

k = 1
for i in range(1, n+1):
    k *= i**2

def make_zeros_array(n):
    return [[float("inf")]*n for _ in range(n)]

def make_adj_matrix(n):
    array = make_zeros_array(n)
    for i in range(n):
        array[i][i] = 0
    for _ in range(n-1):
        i,j = map(lambda x: int(x)-1, input().split())
        array[i][j] = 1
        array[j][i] = 1
    return array

adjacency_matrix = make_adj_matrix(n)

def warshall_floyd(array, n):
  for k in range(n):
    for i in range(n):
      for j in range(n):
        array[i][j]=min(array[i][j], array[i][k]+array[k][j])
  return array

array = warshall_floyd(adjacency_matrix, n)

#pprint(array)

def cal_e_p(p, qs, k, array):
    e_k = 0
    for i in range(n):
        e_k += qs[i] * k/(array[p][i] + 1)**2
    print(int(e_k % 998244353))

for i in range(n):
    cal_e_p(i, qs, k, array)
0