結果

問題 No.654 Air E869120
ユーザー ttttan2ttttan2
提出日時 2019-09-25 16:31:24
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 2,067 bytes
コンパイル時間 1,898 ms
コンパイル使用メモリ 163,540 KB
実行使用メモリ 105,632 KB
最終ジャッジ日時 2023-10-22 07:00:09
合計ジャッジ時間 6,708 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
105,632 KB
testcase_01 AC 55 ms
101,264 KB
testcase_02 AC 55 ms
101,264 KB
testcase_03 AC 55 ms
101,264 KB
testcase_04 AC 55 ms
101,264 KB
testcase_05 AC 55 ms
101,264 KB
testcase_06 AC 48 ms
101,264 KB
testcase_07 AC 42 ms
101,264 KB
testcase_08 AC 39 ms
101,264 KB
testcase_09 AC 40 ms
101,264 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
struct edge{ll to,cap,rev,st,go;};
vector<edge> G[4000010];
bool used[4000010];
void add_edge(ll from,ll to,ll cap,ll st,ll go){
    G[from].push_back((edge){to,cap,(ll)G[to].size(),st,go});
    G[to].push_back((edge){from,0,(ll)G[from].size()-1,0,1000000000000});
}
ll dfs(ll v,ll t,ll f,ll ss){
    if(v==t)return f;
    used[v]=true;
    rep(i,0,G[v].size()){
        edge &e=G[v][i];
        if(used[e.to]==false&&e.cap>0,e.st>=ss){
            ll d=dfs(e.to,t,min(f,e.cap),e.go);
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}
ll max_flow(ll s,ll t){
    ll f=0;
    for(;;){
        memset(used,0,sizeof used);
        ll g=dfs(s,t,1000000000,0);
        if(g==0)return f;
        f+=g;
    }
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n,m,d;cin>>n>>m>>d;
    rep(i,0,m){
        ll u,v,p,q,w;cin>>u>>v>>p>>q>>w;
        add_edge(u,v,w,p,q+d);
    }
    
    ll ans=max_flow(1,n);
    cout<<ans<<endl;
}
0