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