結果
| 問題 | No.3087 University Coloring | 
| コンテスト | |
| ユーザー |  timi | 
| 提出日時 | 2025-04-04 23:01:05 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 501 bytes | 
| コンパイル時間 | 164 ms | 
| コンパイル使用メモリ | 82,256 KB | 
| 実行使用メモリ | 122,628 KB | 
| 最終ジャッジ日時 | 2025-04-04 23:01:24 | 
| 合計ジャッジ時間 | 4,691 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge6 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | TLE * 1 -- * 32 | 
ソースコード
N,M=map(int, input().split())
D=[[] for i in range(N)]
for i in range(M):
  a,b,c=map(int,input().split())
  a-=1;b-=1
  D[a].append((b,c))
  D[b].append((a,c))
  
from collections import deque
d=deque()
#,1は行きがけ、,0は帰りがけ
d.append((0,1,0))
V=[0]*N
ans=0;f=0
while d:
  now,x,c=d.pop()
  if x==1:
    f+=c
    ans=max(ans,2*f)
    V[now]=1
    d.append((now,0,c))
    for nex,c in D[now]:
      if V[nex]==0:
        d.append((nex,1,c))
  else:
    V[now]=0
    f-=c
print(ans)
            
            
            
        