結果
問題 | No.1301 Strange Graph Shortest Path |
ユーザー |
![]() |
提出日時 | 2021-12-18 00:33:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 561 ms / 3,000 ms |
コード長 | 803 bytes |
コンパイル時間 | 1,390 ms |
コンパイル使用メモリ | 100,088 KB |
最終ジャッジ日時 | 2025-01-27 02:47:29 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 33 |
ソースコード
#include <iostream> #include <atcoder/mincostflow> using namespace std; using namespace atcoder; typedef long long ll; int main(){ int i,n,m; cin >> n >> m; mcf_graph<ll,ll> g(n + 4*m); int now = n; for(i=0;i<m;i++){ int u,v,c,d; cin >> u >> v >> c >> d; u--; v--; g.add_edge(u,now,1,c); g.add_edge(now + 1,v,1,c); g.add_edge(v,now,1,c); g.add_edge(now + 1,u,1,c); g.add_edge(now,now + 1,1,0); g.add_edge(u,now + 2,1,d); g.add_edge(now + 3,v,1,d); g.add_edge(v,now + 2,1,d); g.add_edge(now + 3,u,1,d); g.add_edge(now + 2,now + 3,1,0); now += 4; } auto ret = g.flow(0,n - 1,2); cout << ret.second/2 << endl; //cout << ret.first << " " << ret.second << endl; //cout << g.flow(0,n - 1,2).second << endl; }