結果
問題 | No.654 Air E869120 |
ユーザー | nvt4s |
提出日時 | 2019-06-15 17:06:09 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,930 bytes |
コンパイル時間 | 1,872 ms |
コンパイル使用メモリ | 178,048 KB |
実行使用メモリ | 252,928 KB |
最終ジャッジ日時 | 2024-11-19 03:14:14 |
合計ジャッジ時間 | 22,811 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 66 ms
130,688 KB |
testcase_01 | AC | 66 ms
252,672 KB |
testcase_02 | AC | 66 ms
130,432 KB |
testcase_03 | AC | 65 ms
252,544 KB |
testcase_04 | AC | 90 ms
130,560 KB |
testcase_05 | AC | 62 ms
252,672 KB |
testcase_06 | AC | 65 ms
130,688 KB |
testcase_07 | AC | 63 ms
125,184 KB |
testcase_08 | AC | 62 ms
125,312 KB |
testcase_09 | AC | 61 ms
125,312 KB |
testcase_10 | AC | 1,041 ms
125,440 KB |
testcase_11 | AC | 617 ms
125,456 KB |
testcase_12 | AC | 729 ms
125,440 KB |
testcase_13 | AC | 933 ms
125,440 KB |
testcase_14 | AC | 505 ms
125,440 KB |
testcase_15 | AC | 586 ms
125,436 KB |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
testcase_18 | TLE | - |
testcase_19 | TLE | - |
testcase_20 | AC | 115 ms
128,896 KB |
testcase_21 | AC | 142 ms
128,896 KB |
testcase_22 | AC | 76 ms
128,640 KB |
testcase_23 | AC | 92 ms
128,768 KB |
testcase_24 | WA | - |
testcase_25 | AC | 71 ms
128,000 KB |
testcase_26 | AC | 74 ms
128,384 KB |
testcase_27 | AC | 73 ms
130,432 KB |
testcase_28 | WA | - |
testcase_29 | AC | 73 ms
129,920 KB |
testcase_30 | AC | 362 ms
249,856 KB |
testcase_31 | AC | 309 ms
248,192 KB |
testcase_32 | AC | 319 ms
250,288 KB |
testcase_33 | AC | 289 ms
249,216 KB |
testcase_34 | AC | 287 ms
248,120 KB |
testcase_35 | AC | 59 ms
125,312 KB |
testcase_36 | AC | 58 ms
125,312 KB |
testcase_37 | AC | 57 ms
125,312 KB |
testcase_38 | AC | 58 ms
125,312 KB |
testcase_39 | AC | 59 ms
252,928 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 = 1000000000000000010;//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 5000010 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 = 5000000; add_edge(s, 0, INFL); rep(i, N){ rep(j, T-1){ add_edge(j + T * i, j+1 + T * i, INFL); } } cout << max_flow(s, T * N - 1) << endl; }