結果
問題 | No.748 yuki国のお財布事情 |
ユーザー | torikumino |
提出日時 | 2018-10-28 16:49:50 |
言語 | Python3 (3.11.6 + numpy 1.26.0 + scipy 1.11.3) |
結果 |
TLE
|
実行時間 | - |
コード長 | 783 bytes |
コンパイル時間 | 505 ms |
コンパイル使用メモリ | 10,868 KB |
実行使用メモリ | 816,868 KB |
最終ジャッジ日時 | 2023-08-12 08:05:07 |
合計ジャッジ時間 | 7,083 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 16 ms
8,212 KB |
testcase_01 | AC | 15 ms
8,128 KB |
testcase_02 | AC | 16 ms
8,144 KB |
testcase_03 | AC | 16 ms
7,756 KB |
testcase_04 | AC | 15 ms
8,116 KB |
testcase_05 | AC | 15 ms
8,252 KB |
testcase_06 | AC | 16 ms
8,160 KB |
testcase_07 | AC | 15 ms
8,136 KB |
testcase_08 | AC | 17 ms
8,004 KB |
testcase_09 | AC | 16 ms
8,296 KB |
testcase_10 | AC | 17 ms
8,076 KB |
testcase_11 | AC | 16 ms
8,100 KB |
testcase_12 | AC | 16 ms
8,200 KB |
testcase_13 | AC | 202 ms
22,524 KB |
testcase_14 | TLE | - |
testcase_15 | AC | 338 ms
34,436 KB |
testcase_16 | MLE | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
ソースコード
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[y] += s[x] 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)