結果

問題 No.3107 Listening
ユーザー MasKoaTSMasKoaTS
提出日時 2024-04-01 22:03:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,194 ms / 2,000 ms
コード長 634 bytes
コンパイル時間 203 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 263,424 KB
最終ジャッジ日時 2024-04-01 22:04:19
合計ジャッジ時間 38,272 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 38 ms
53,460 KB
testcase_02 AC 35 ms
53,460 KB
testcase_03 AC 735 ms
185,904 KB
testcase_04 AC 195 ms
92,688 KB
testcase_05 AC 230 ms
101,604 KB
testcase_06 AC 219 ms
95,360 KB
testcase_07 AC 422 ms
132,372 KB
testcase_08 AC 320 ms
119,580 KB
testcase_09 AC 426 ms
126,840 KB
testcase_10 AC 805 ms
195,256 KB
testcase_11 AC 1,056 ms
232,824 KB
testcase_12 AC 312 ms
115,740 KB
testcase_13 AC 742 ms
174,696 KB
testcase_14 AC 383 ms
132,268 KB
testcase_15 AC 351 ms
115,772 KB
testcase_16 AC 182 ms
93,360 KB
testcase_17 AC 197 ms
100,420 KB
testcase_18 AC 149 ms
85,292 KB
testcase_19 AC 521 ms
140,048 KB
testcase_20 AC 683 ms
164,504 KB
testcase_21 AC 1,097 ms
245,708 KB
testcase_22 AC 787 ms
177,796 KB
testcase_23 AC 982 ms
225,144 KB
testcase_24 AC 1,060 ms
230,884 KB
testcase_25 AC 579 ms
161,580 KB
testcase_26 AC 200 ms
100,564 KB
testcase_27 AC 530 ms
150,208 KB
testcase_28 AC 869 ms
191,264 KB
testcase_29 AC 889 ms
203,656 KB
testcase_30 AC 352 ms
122,104 KB
testcase_31 AC 476 ms
134,268 KB
testcase_32 AC 820 ms
196,064 KB
testcase_33 AC 1,142 ms
263,424 KB
testcase_34 AC 1,171 ms
263,424 KB
testcase_35 AC 1,165 ms
263,424 KB
testcase_36 AC 1,194 ms
263,424 KB
testcase_37 AC 1,158 ms
263,424 KB
testcase_38 AC 1,158 ms
263,424 KB
testcase_39 AC 1,152 ms
263,424 KB
testcase_40 AC 1,173 ms
263,296 KB
testcase_41 AC 1,158 ms
263,424 KB
testcase_42 AC 1,181 ms
263,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def maximal_matching(G):
    M = set()  # Initialize an empty set for the matching
    sorted_edges = sorted(G.edges, key=lambda e: e.weight)  # Sort edges by weight
    for edge in sorted_edges:
        u, v = edge.vertices
        if u not in M and v not in M:
            M.add(edge)
    return M

n, m = map(int, input().split())
edges = [[x - 1 for x in map(int, input().split())] + [i] for i in range(1, m + 1)]
edges.sort(key = lambda e : e[2])
st = set([])
ans = []
for u, v, w in edges:
    if(u not in st and v not in st):
        ans.append(w)
        st.add(u)
        st.add(v)
print(len(ans))
for x in ans:
    print(x)
0