結果
問題 |
No.654 Air E869120
|
ユーザー |
![]() |
提出日時 | 2024-02-03 20:46:49 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,272 bytes |
コンパイル時間 | 3,387 ms |
コンパイル使用メモリ | 276,004 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-28 10:59:13 |
合計ジャッジ時間 | 5,285 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 25 WA * 5 RE * 5 |
ソースコード
#include <atcoder/maxflow> #include <bits/stdc++.h> using namespace std; using ll = long long; int main() { cin.tie(0)->sync_with_stdio(0); ll N, M, d; cin >> N >> M >> d; vector<ll> u(M), v(M), p(M), q(M), w(M); for (ll i = 0; i < M; i++) { cin >> u[i] >> v[i] >> p[i] >> q[i] >> w[i]; u[i]--; v[i]--; } map<pair<ll, ll>, ll> index; // {city_id, time} -> index of G vector<vector<ll>> times(N); ll id = 0; index[{ 0, 0 }] = id++; times[0].push_back(0); times[N - 1].push_back(1e9); for (ll i = 0; i < M; i++) { index[{ u[i], p[i] }] = id++; index[{ v[i], q[i] + d }] = id++; times[u[i]].push_back(p[i]); times[v[i]].push_back(q[i] + d); } index[{ N - 1, 1e9 }] = id++; atcoder::mf_graph<ll> G(id); for (ll i = 0; i < M; i++) { G.add_edge(index[{ u[i], p[i] }], index[{ v[i], q[i] + d }], w[i]); } for (ll i = 0; i < N; i++) { sort(times[i].begin(), times[i].end()); for (ll j = 0; j < times[i].size() - 1; j++) { G.add_edge(index[{ i, times[i][j] }], index[{ i, times[i][j + 1] }], LLONG_MAX); } } ll flow = G.flow(index[{ 0, 0 }], index[{ N - 1, 1e9 }]); cout << flow << endl; }