結果
| 問題 |
No.748 yuki国のお財布事情
|
| コンテスト | |
| ユーザー |
torikumino
|
| 提出日時 | 2018-10-28 16:47:45 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 783 bytes |
| コンパイル時間 | 338 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 902,408 KB |
| 最終ジャッジ日時 | 2024-11-19 07:09:13 |
| 合計ジャッジ時間 | 36,602 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 MLE * 1 |
| other | AC * 11 TLE * 9 MLE * 6 |
ソースコード
n,m,k=map(int,input().split())
g = [['-']*n for _ in range(n)]
v=[]
for _ in range(m):
i,j,c=map(int,input().split())
g[i-1][j-1] = c
g[j-1][i-1] = c
v.append((c,i-1,j-1))
p = list(range(len(g)))
s = [1]*len(g)
def f(x):
if x == p[x]:
return x
p[x] = f(p[x])
return p[x]
def u(x, y):
x = f(x)
y = f(y)
if s[x] > s[y]:
x, y = y, x
p[x] = p[y]
s[x] += s[y]
e = {(int(c),i,j) for i,r in enumerate(g)
for j,c in enumerate(r) if c != '-'}
pp =0
for _ in range(k):
c,i,j=v[int(input())-1]
e.remove((c,i,j))
e.remove((c,j,i))
e.add((0,i,j))
e.add((0,j,i))
pp += c
e = sorted(e)
r = 0
d = 0
for c,i,j in e:
if f(i)==f(j):
r += c
continue
u(i,j)
d += c
print((r-d)//2)
torikumino