結果
問題 | No.654 Air E869120 |
ユーザー | nvt4s |
提出日時 | 2019-06-15 17:34:03 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,226 bytes |
コンパイル時間 | 1,969 ms |
コンパイル使用メモリ | 179,900 KB |
実行使用メモリ | 16,664 KB |
最終ジャッジ日時 | 2024-11-19 04:20:38 |
合計ジャッジ時間 | 13,753 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
15,016 KB |
testcase_01 | AC | 5 ms
16,632 KB |
testcase_02 | AC | 4 ms
14,972 KB |
testcase_03 | AC | 4 ms
8,008 KB |
testcase_04 | AC | 5 ms
8,128 KB |
testcase_05 | AC | 5 ms
8,008 KB |
testcase_06 | AC | 5 ms
8,088 KB |
testcase_07 | AC | 4 ms
8,196 KB |
testcase_08 | AC | 4 ms
8,200 KB |
testcase_09 | AC | 5 ms
8,236 KB |
testcase_10 | AC | 117 ms
8,228 KB |
testcase_11 | AC | 62 ms
8,224 KB |
testcase_12 | AC | 71 ms
8,140 KB |
testcase_13 | AC | 108 ms
8,220 KB |
testcase_14 | AC | 49 ms
8,284 KB |
testcase_15 | AC | 57 ms
8,136 KB |
testcase_16 | WA | - |
testcase_17 | TLE | - |
testcase_18 | TLE | - |
testcase_19 | TLE | - |
testcase_20 | AC | 9 ms
8,384 KB |
testcase_21 | AC | 11 ms
8,352 KB |
testcase_22 | WA | - |
testcase_23 | AC | 8 ms
8,376 KB |
testcase_24 | WA | - |
testcase_25 | AC | 7 ms
8,344 KB |
testcase_26 | AC | 6 ms
8,420 KB |
testcase_27 | AC | 7 ms
8,444 KB |
testcase_28 | WA | - |
testcase_29 | AC | 7 ms
8,380 KB |
testcase_30 | RE | - |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | AC | 5 ms
8,236 KB |
testcase_36 | AC | 4 ms
8,128 KB |
testcase_37 | AC | 4 ms
8,096 KB |
testcase_38 | AC | 4 ms
8,008 KB |
testcase_39 | AC | 4 ms
16,664 KB |
ソースコード
#ifndef _GLIBCXX_NO_ASSERT #include <cassert> #endif #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #if __cplusplus >= 201103L #include <ccomplex> #include <cfenv> #include <cinttypes> #include <cstdbool> #include <cstdint> #include <ctgmath> #include <cwchar> #include <cwctype> #endif // C++ #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #if __cplusplus >= 201103L #include <array> #include <atomic> #include <chrono> #include <condition_variable> #include <forward_list> #include <future> #include <initializer_list> #include <mutex> #include <random> #include <ratio> #include <regex> #include <scoped_allocator> #include <system_error> #include <thread> #include <tuple> #include <typeindex> #include <type_traits> #include <unordered_map> #include <unordered_set> #endif using namespace std; #define rep(i, n) for(ll i = 0; i < n; i++) #define revrep(i, n) for(ll i = n-1; i >= 0; i--) typedef long long ll; typedef pair<int,int> Pint; typedef pair<ll, ll> P; typedef vector<ll> vec; typedef vector<vec> mat; //typedef pair<int, pair<int, int>> P; //typedef tuple<int,int,int> T; ll INFL = 10000000000000;//10^18 = 2^60 int INF = 1000000000;//10^9 ll MOD = 1000000007; //vector<int> dy = {0,0,1,-1}; //vector<int> dx = {1,-1,0,0}; #define MAX_V 200010 struct edge {ll to, cap, rev;}; vector<vector<edge> > G(MAX_V); bool used[MAX_V]; void add_edge(ll from, ll to, ll cap){ edge F; edge T; F.to = to; F.cap = cap; F.rev = G[to].size(); G[from].push_back(F); T.to = from; T.cap = 0; T.rev = G[from].size() - 1; G[to].push_back(T); } ll dfs(ll v, ll t, ll f){ if(v == t) return f; used[v] = true; for(ll i = 0; i < G[v].size(); i++){ edge &e = G[v][i]; if(!used[e.to] && e.cap > 0){ ll d = dfs(e.to, t, min(f, e.cap)); 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 flow = 0; while(1){ memset(used, 0, sizeof(used)); ll f = dfs(s, t, INF); if(f == 0) return flow; flow += f; } } ll N, M, d; vector<ll> u(1010), v(1010), p(1010), q(1010), w(1010); ll compress(vector<ll> &p, vector<ll> &q){ vector<ll> xs; xs.push_back(0LL); xs.push_back(1000000000); rep(i, M){ xs.push_back(p[i]); xs.push_back(q[i]); } sort(xs.begin(), xs.end()); xs.erase(unique(xs.begin(), xs.end()), xs.end()); rep(i, M){ p[i] = lower_bound(xs.begin(), xs.end(), p[i]) - xs.begin(); q[i] = lower_bound(xs.begin(), xs.end(), q[i]) - xs.begin(); } return xs.size(); } int main(void){ cin >> N >> M >> d; rep(i, M){ cin >> u[i] >> v[i] >> p[i] >> q[i] >> w[i]; u[i]--, v[i]--; q[i] += d; if(q[i] >= 1000000000){ w[i] = 0; p[i] = q[i] = u[i] = v[i] = 0; } } ll T = compress(p, q); rep(i, M){ add_edge(p[i] + T * u[i], q[i] + T * v[i], w[i]); } ll s = 10000; add_edge(s, 0, INFL); rep(i, N){ vector<ll> xs; xs.push_back(0); xs.push_back(T-1); rep(j, M){ if(u[j] == i){ xs.push_back(p[j]); } if(v[j] == i){ xs.push_back(q[j]); } } sort(xs.begin(), xs.end()); xs.erase(unique(xs.begin(), xs.end()), xs.end()); rep(j, xs.size() - 1){ add_edge(xs[j] + T * i, xs[j+1] + T * i, INFL); } } cout << max_flow(s, T * N - 1) << endl; }