結果

問題 No.654 Air E869120
ユーザー kuhakukuhaku
提出日時 2020-08-19 03:16:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,432 bytes
コンパイル時間 2,625 ms
コンパイル使用メモリ 212,988 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-20 08:09:37
合計ジャッジ時間 12,449 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,704 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 4 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 7 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1,570 ms
5,376 KB
testcase_11 AC 814 ms
5,376 KB
testcase_12 AC 878 ms
5,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 TLE -
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>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define rep(i, n) REP(i, 0, n)
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
constexpr ll LINF = 1e18L+1;
constexpr ll MOD = 1e9+7;

using Graph = map<P, map<P, ll>>;
set<P> used;
Graph graph;

ll dfs(P v, ll t, ll f){
	cerr << v.first << " " << v.second << endl;
	if (v.first == t) return f;
	auto p = graph.lower_bound(v);
	while(p->first.first == v.first){
		for(auto &q : p->second){
			if (used.find(q.first) == used.end() && q.second) {
				used.insert(q.first);
				ll d = dfs(q.first, t, min(f, q.second));
				if (d) {
					q.second -= d;
					graph[q.first][v] += d;
					return d;
				}
			}
		}
		++p;
	}
	return 0;
}

// 最大流を求める
ll ford_fulkerson(ll s, ll t){
	ll res = 0;
	while(true){
		used.clear();
		ll f = dfs({s, 0}, t, LINF);
		cerr << f << endl;
		if (!f) break;
		res += f;
	}
	return res;
}

int main(void) {
	ll V, E, d;
	cin >> V >> E >> d;
	rep(i, E){
		ll u, v, p, q, w;
		cin >> u >> v >> p >> q >> w;
		--u, --v, q += d;
		graph[{u, p}][{v, q}] = w;
	}
	cout << ford_fulkerson(0, V - 1) << endl;

	return 0;
}
0