結果
問題 | No.3087 University Coloring |
ユーザー |
|
提出日時 | 2025-04-04 22:58:59 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 977 bytes |
コンパイル時間 | 246 ms |
コンパイル使用メモリ | 82,580 KB |
実行使用メモリ | 316,928 KB |
最終ジャッジ日時 | 2025-04-04 22:59:11 |
合計ジャッジ時間 | 9,641 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 3 WA * 12 TLE * 1 -- * 17 |
ソースコード
import syssys.setrecursionlimit(10**8)n,m=map(int,input().split())connect=[[] for _ in range(n)]weight=[]ans=0for i in range(m):a,b,c=map(int,input().split())a-=1b-=1connect[a].append((b,i))connect[b].append((a,i))weight.append(c)ans+=cdef DFS(now,past,edge):global visitedglobal ansfor to,ed in connect[now]:if visited[to] and to!=past and len(edge)>=2:idx=0check=edfor i in range(len(edge)):if check==ed:idx=ibreakret=10**18for i in range(idx,len(edge)):ret=min(ret,weight[edge[i]])ans-=retreturnelse:if not visited[to]:visited[to]=Trueedge.append(ed)DFS(to,now,edge)edge.pop()visited=[False]*nvisited[0]=TrueDFS(0,-1,[])print(ans*2)