結果

問題 No.1301 Strange Graph Shortest Path
ユーザー pockynypockyny
提出日時 2021-12-18 00:33:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 523 ms / 3,000 ms
コード長 803 bytes
コンパイル時間 2,295 ms
コンパイル使用メモリ 102,372 KB
実行使用メモリ 157,936 KB
最終ジャッジ日時 2023-10-13 04:03:48
合計ジャッジ時間 20,462 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 437 ms
152,692 KB
testcase_03 AC 378 ms
134,764 KB
testcase_04 AC 512 ms
157,936 KB
testcase_05 AC 428 ms
152,856 KB
testcase_06 AC 464 ms
145,044 KB
testcase_07 AC 431 ms
148,740 KB
testcase_08 AC 396 ms
137,444 KB
testcase_09 AC 351 ms
137,052 KB
testcase_10 AC 348 ms
136,652 KB
testcase_11 AC 428 ms
149,420 KB
testcase_12 AC 420 ms
151,160 KB
testcase_13 AC 379 ms
152,640 KB
testcase_14 AC 450 ms
138,464 KB
testcase_15 AC 366 ms
139,996 KB
testcase_16 AC 470 ms
156,636 KB
testcase_17 AC 438 ms
156,736 KB
testcase_18 AC 436 ms
142,300 KB
testcase_19 AC 382 ms
146,848 KB
testcase_20 AC 433 ms
143,972 KB
testcase_21 AC 449 ms
153,680 KB
testcase_22 AC 466 ms
147,120 KB
testcase_23 AC 379 ms
154,760 KB
testcase_24 AC 460 ms
145,848 KB
testcase_25 AC 459 ms
156,396 KB
testcase_26 AC 441 ms
148,620 KB
testcase_27 AC 377 ms
149,412 KB
testcase_28 AC 365 ms
147,008 KB
testcase_29 AC 523 ms
156,808 KB
testcase_30 AC 395 ms
155,136 KB
testcase_31 AC 438 ms
155,852 KB
testcase_32 AC 1 ms
4,352 KB
testcase_33 AC 308 ms
156,828 KB
testcase_34 AC 397 ms
157,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0