結果

問題 No.2200 Weird Shortest Path
ユーザー 👑 p-adicp-adic
提出日時 2023-05-31 13:52:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,212 ms / 2,000 ms
コード長 317 bytes
コンパイル時間 365 ms
コンパイル使用メモリ 10,804 KB
実行使用メモリ 46,904 KB
最終ジャッジ日時 2023-08-28 01:31:40
合計ジャッジ時間 28,086 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,788 KB
testcase_01 AC 14 ms
7,828 KB
testcase_02 AC 14 ms
7,728 KB
testcase_03 AC 17 ms
7,796 KB
testcase_04 AC 25 ms
8,332 KB
testcase_05 AC 15 ms
7,788 KB
testcase_06 AC 15 ms
7,744 KB
testcase_07 AC 16 ms
7,780 KB
testcase_08 AC 23 ms
8,176 KB
testcase_09 AC 19 ms
7,828 KB
testcase_10 AC 15 ms
7,784 KB
testcase_11 AC 15 ms
7,844 KB
testcase_12 AC 15 ms
7,820 KB
testcase_13 AC 14 ms
7,916 KB
testcase_14 AC 15 ms
7,788 KB
testcase_15 AC 19 ms
8,236 KB
testcase_16 AC 15 ms
7,796 KB
testcase_17 AC 329 ms
20,076 KB
testcase_18 AC 604 ms
29,836 KB
testcase_19 AC 1,007 ms
42,972 KB
testcase_20 AC 985 ms
42,940 KB
testcase_21 AC 379 ms
23,476 KB
testcase_22 AC 514 ms
27,312 KB
testcase_23 AC 1,056 ms
44,908 KB
testcase_24 AC 174 ms
14,708 KB
testcase_25 AC 985 ms
42,832 KB
testcase_26 AC 1,072 ms
44,328 KB
testcase_27 AC 364 ms
22,096 KB
testcase_28 AC 785 ms
35,688 KB
testcase_29 AC 1,091 ms
45,060 KB
testcase_30 AC 1,061 ms
44,116 KB
testcase_31 AC 633 ms
30,920 KB
testcase_32 AC 1,097 ms
46,368 KB
testcase_33 AC 1,114 ms
46,380 KB
testcase_34 AC 1,084 ms
46,372 KB
testcase_35 AC 1,089 ms
46,904 KB
testcase_36 AC 1,108 ms
46,348 KB
testcase_37 AC 1,098 ms
46,368 KB
testcase_38 AC 1,099 ms
46,724 KB
testcase_39 AC 541 ms
29,664 KB
testcase_40 AC 896 ms
39,804 KB
testcase_41 AC 518 ms
26,468 KB
testcase_42 AC 894 ms
36,696 KB
testcase_43 AC 1,187 ms
46,448 KB
testcase_44 AC 1,203 ms
46,352 KB
testcase_45 AC 1,212 ms
46,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

I,R=input,range
def J():
	return map(int,I().split())
N,M=J()
p=[i for i in R(N)]
c=[1]*N
def r(i):
	m=p[i]
	while i!=m:
		p[i]=i=p[m]
		m=p[i]
	return i
E=[0]*M
for i in R(M):
	a,b,w=J()
	E[i]=w,a-1,b-1
E.sort()
s=0
for i in R(M):
	w,a,b=E[i]
	a,b=r(a),r(b)
	if a!=b:
		s,c[b],p[a]=s+c[a]*c[b]*w,c[b]+c[a],b
print(s)
0