結果

問題 No.654 Air E869120
ユーザー yutasyutas
提出日時 2020-07-25 19:46:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,675 bytes
コンパイル時間 1,532 ms
コンパイル使用メモリ 169,320 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 21:30:27
合計ジャッジ時間 3,579 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M, D;
struct edge {int to, cap, rev, time_p, time_q;};

vector <edge> Graph[1005];
bool used[1005];

int Add_Edge(int from, int to, int cap, int time_p, int time_q){
  int rev = Graph[to].size();
  Graph[from].push_back((edge){to, cap, rev, time_p, time_q});

  rev = Graph[from].size() - 1;
  Graph[to].push_back((edge){from, 0, rev, time_p, time_q});

  return 0;
}

int DFS(int S, int T, int Flow, int Time){
  if (S == T) return Flow;

  used[S] = true;
  for (int i = 0; i < Graph[S].size(); i++){
    edge &E = Graph[S][i];

    if (!used[E.to] && E.cap > 0 && E.time_p >= Time){
      int F = DFS(E.to, T, min(Flow, E.cap), E.time_q + D);

      if (F > 0){
        E.cap -= F;
        Graph[E.to][E.rev].cap += F;
        return F;
      }
    }
  }
  return 0;
}

int main(){
  cin >> N >> M >> D;
  for (int i = 0; i < M; i++){
    int U, V, P, Q, W;
    cin >> U >> V >> P >> Q >> W;
    Add_Edge(U, V, W, P, Q);
  }

  int ans = 0;
  while (true){
    fill(used, used + N + 1, false);
    int Flow = DFS(1, N, MOD, 0);
    if (Flow == 0) break;
    ans += Flow;
  }
  cout << ans << endl;

  return 0;
}
0