結果
問題 | No.654 Air E869120 |
ユーザー | nvt4s |
提出日時 | 2019-06-15 17:42:55 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 4,233 bytes |
コンパイル時間 | 1,909 ms |
コンパイル使用メモリ | 180,252 KB |
実行使用メモリ | 8,288 KB |
最終ジャッジ日時 | 2024-11-19 04:41:39 |
合計ジャッジ時間 | 6,579 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
8,260 KB |
testcase_01 | AC | 5 ms
8,128 KB |
testcase_02 | AC | 5 ms
8,100 KB |
testcase_03 | AC | 4 ms
8,160 KB |
testcase_04 | AC | 4 ms
8,204 KB |
testcase_05 | AC | 5 ms
8,144 KB |
testcase_06 | AC | 4 ms
8,240 KB |
testcase_07 | AC | 4 ms
8,204 KB |
testcase_08 | AC | 4 ms
8,088 KB |
testcase_09 | AC | 5 ms
8,140 KB |
testcase_10 | AC | 117 ms
8,220 KB |
testcase_11 | AC | 62 ms
8,288 KB |
testcase_12 | AC | 73 ms
8,280 KB |
testcase_13 | AC | 109 ms
8,228 KB |
testcase_14 | AC | 50 ms
8,276 KB |
testcase_15 | AC | 57 ms
8,272 KB |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | AC | 6 ms
8,160 KB |
testcase_36 | AC | 4 ms
8,140 KB |
testcase_37 | AC | 5 ms
8,140 KB |
testcase_38 | AC | 5 ms
8,152 KB |
testcase_39 | AC | 5 ms
8,156 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] = 0; u[i] = v[i] = -1; } } 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; }