結果
問題 | No.1320 Two Type Min Cost Cycle |
ユーザー |
![]() |
提出日時 | 2020-12-17 09:26:12 |
言語 | cLay (20241019-1) |
結果 |
AC
|
実行時間 | 21 ms / 2,000 ms |
コード長 | 647 bytes |
コンパイル時間 | 3,541 ms |
コンパイル使用メモリ | 178,464 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-05 14:50:52 |
合計ジャッジ時間 | 5,079 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 57 |
ソースコード
int u[2000],v[2000],w[2000];ll z=ll_inf;wgraph<int> g;DijkstraHeap<ll> h;{ll@dir,@n,@m;rd((u--,v--,w)(m));if(dir==0){g.setEdge(n,m,u,v,w);}else{g.setDirectEdge(n,m,u,v,w);}h.walloc(n);rep(t,n){rep(a,g.es[t]){int s=g.edge[t][a];if(s>t){h.init(n);h.change(s,g.cost[t][a]);while(h.size){int i=h.pop();ll iv=h.val[i];if(iv>=z){break;}if(i==t){z=iv;break;}else if(i>t){rep(k,g.es[i]){int j=g.edge[i][k];if(i!=s||j!=t){h.change(j,iv+g.cost[i][k]);}}}}}}}wt(z==ll_inf?-1:z);}