結果

問題 No.1301 Strange Graph Shortest Path
ユーザー monnumonnu
提出日時 2021-04-19 23:08:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 243 ms / 3,000 ms
コード長 704 bytes
コンパイル時間 4,237 ms
コンパイル使用メモリ 245,612 KB
実行使用メモリ 63,664 KB
最終ジャッジ日時 2023-09-17 08:32:19
合計ジャッジ時間 13,474 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,356 KB
testcase_02 AC 213 ms
61,084 KB
testcase_03 AC 182 ms
53,684 KB
testcase_04 AC 236 ms
63,092 KB
testcase_05 AC 203 ms
60,684 KB
testcase_06 AC 219 ms
58,704 KB
testcase_07 AC 211 ms
59,316 KB
testcase_08 AC 188 ms
55,884 KB
testcase_09 AC 192 ms
55,200 KB
testcase_10 AC 185 ms
55,300 KB
testcase_11 AC 213 ms
60,304 KB
testcase_12 AC 211 ms
60,560 KB
testcase_13 AC 207 ms
61,120 KB
testcase_14 AC 211 ms
55,884 KB
testcase_15 AC 195 ms
55,864 KB
testcase_16 AC 235 ms
62,748 KB
testcase_17 AC 218 ms
62,768 KB
testcase_18 AC 205 ms
57,684 KB
testcase_19 AC 204 ms
58,592 KB
testcase_20 AC 216 ms
59,032 KB
testcase_21 AC 213 ms
60,496 KB
testcase_22 AC 227 ms
59,168 KB
testcase_23 AC 208 ms
61,148 KB
testcase_24 AC 219 ms
58,232 KB
testcase_25 AC 230 ms
63,664 KB
testcase_26 AC 212 ms
59,820 KB
testcase_27 AC 209 ms
59,840 KB
testcase_28 AC 194 ms
58,312 KB
testcase_29 AC 243 ms
63,472 KB
testcase_30 AC 213 ms
61,864 KB
testcase_31 AC 221 ms
61,676 KB
testcase_32 AC 2 ms
4,356 KB
testcase_33 AC 177 ms
62,452 KB
testcase_34 AC 200 ms
63,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll=long long;
using Graph=vector<vector<pair<int,int>>>;
#define MAX 200003
#define MOD 1000000007
#define INF 1000000000000000000

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> u(M),v(M);
  vector<ll> c(M),d(M);
  for(int i=0;i<M;i++){
    cin>>u[i]>>v[i]>>c[i]>>d[i];
    u[i]--;
    v[i]--;
  }

  mcf_graph<int,ll> G(N+2);
  for(int i=0;i<M;i++){
    G.add_edge(u[i],v[i],1,c[i]);
    G.add_edge(u[i],v[i],1,d[i]);
    G.add_edge(v[i],u[i],1,c[i]);
    G.add_edge(v[i],u[i],1,d[i]);
  }

  G.add_edge(N,0,2,0);
  G.add_edge(N-1,N+1,2,0);
  pair<int,ll> p=G.flow(N,N+1);
  cout<<p.second<<endl;
}
0