結果
| 問題 |
No.654 Air E869120
|
| コンテスト | |
| ユーザー |
yutas
|
| 提出日時 | 2020-07-25 19:46:40 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,675 bytes |
| コンパイル時間 | 1,539 ms |
| コンパイル使用メモリ | 170,240 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-27 13:59:28 |
| 合計ジャッジ時間 | 2,803 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 WA * 1 |
| other | AC * 11 WA * 24 |
ソースコード
#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;
}
yutas