From 0cced61690da139c52e873c01ac032857bfb0484 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sat, 5 Nov 2022 13:59:05 +0800 Subject: [PATCH] =?UTF-8?q?#1733.=20=E3=80=90NOIP=202022=20=E6=A8=A1?= =?UTF-8?q?=E6=8B=9F=E8=B5=9B=20by=20AzusaCat=E3=80=91=E5=B0=8F=E9=BB=84?= =?UTF-8?q?=E9=B8=AD=E4=B8=8E=E6=9C=80=E7=9F=AD=E8=B7=AF=EF=BC=88path?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://sjzezoj.com/submission/63370 --- S2OJ/1733/1733.cpp | 118 ++++++++++++++++++++++++++++++++++++ S2OJ/1733/data/ex_path1.ans | 3 + S2OJ/1733/data/ex_path1.in | 3 + S2OJ/1733/data/ex_path2.ans | 3 + S2OJ/1733/data/ex_path2.in | 3 + S2OJ/1733/data/ex_path3.ans | 3 + S2OJ/1733/data/ex_path3.in | 3 + S2OJ/1733/data/path1.ans | 3 + S2OJ/1733/data/path1.in | 3 + S2OJ/1733/data/path10.ans | 3 + S2OJ/1733/data/path10.in | 3 + S2OJ/1733/data/path2.ans | 3 + S2OJ/1733/data/path2.in | 3 + S2OJ/1733/data/path3.ans | 3 + S2OJ/1733/data/path3.in | 3 + S2OJ/1733/data/path4.ans | 3 + S2OJ/1733/data/path4.in | 3 + S2OJ/1733/data/path5.ans | 3 + S2OJ/1733/data/path5.in | 3 + S2OJ/1733/data/path6.ans | 3 + S2OJ/1733/data/path6.in | 3 + S2OJ/1733/data/path7.ans | 3 + S2OJ/1733/data/path7.in | 3 + S2OJ/1733/data/path8.ans | 3 + S2OJ/1733/data/path8.in | 3 + S2OJ/1733/data/path9.ans | 3 + S2OJ/1733/data/path9.in | 3 + S2OJ/1733/data/problem.conf | 3 + 28 files changed, 199 insertions(+) create mode 100644 S2OJ/1733/1733.cpp create mode 100644 S2OJ/1733/data/ex_path1.ans create mode 100644 S2OJ/1733/data/ex_path1.in create mode 100644 S2OJ/1733/data/ex_path2.ans create mode 100644 S2OJ/1733/data/ex_path2.in create mode 100644 S2OJ/1733/data/ex_path3.ans create mode 100644 S2OJ/1733/data/ex_path3.in create mode 100644 S2OJ/1733/data/path1.ans create mode 100644 S2OJ/1733/data/path1.in create mode 100644 S2OJ/1733/data/path10.ans create mode 100644 S2OJ/1733/data/path10.in create mode 100644 S2OJ/1733/data/path2.ans create mode 100644 S2OJ/1733/data/path2.in create mode 100644 S2OJ/1733/data/path3.ans create mode 100644 S2OJ/1733/data/path3.in create mode 100644 S2OJ/1733/data/path4.ans create mode 100644 S2OJ/1733/data/path4.in create mode 100644 S2OJ/1733/data/path5.ans create mode 100644 S2OJ/1733/data/path5.in create mode 100644 S2OJ/1733/data/path6.ans create mode 100644 S2OJ/1733/data/path6.in create mode 100644 S2OJ/1733/data/path7.ans create mode 100644 S2OJ/1733/data/path7.in create mode 100644 S2OJ/1733/data/path8.ans create mode 100644 S2OJ/1733/data/path8.in create mode 100644 S2OJ/1733/data/path9.ans create mode 100644 S2OJ/1733/data/path9.in create mode 100644 S2OJ/1733/data/problem.conf diff --git a/S2OJ/1733/1733.cpp b/S2OJ/1733/1733.cpp new file mode 100644 index 00000000..ef9f17f0 --- /dev/null +++ b/S2OJ/1733/1733.cpp @@ -0,0 +1,118 @@ +#include +#include +#include +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 5e4 + 5, + Q = 3e5 + 5; + +int n, q, k, l; +long long t; +std::tuple edges[Q]; +std::vector ans; +std::array>, N> g; +std::array vis; +std::array dist; + +void dijkstra() { + std::fill(vis.begin(), vis.end(), false); + std::fill(dist.begin(), dist.end(), std::numeric_limits::max() / 3); + + std::priority_queue, std::vector>, std::greater>> q; + + q.emplace(0, 1); + dist[1] = 0; + + while (!q.empty()) { + int u = q.top().second; + q.pop(); + + if (vis[u]) continue; + vis[u] = true; + + for (auto e : g[u]) { + int v = e.first; + long long w = e.second; + + if (dist[v] > dist[u] + w) { + dist[v] = dist[u] + w; + q.emplace(dist[v], v); + } + } + } +} + +bool check(int l, int r) { + std::fill(g.begin(), g.end(), std::vector>()); + + for (int i = l; i <= r; i++) { + int u = std::get<0>(edges[i]), + v = std::get<1>(edges[i]); + long long w = std::get<2>(edges[i]); + + g[u].emplace_back(v, w); + g[v].emplace_back(u, w); + } + + dijkstra(); + + return dist[n] <= t; +} + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> n >> q >> t; + + k = std::__lg(q) + 1; + + for (int i = 1; i <= q; i++) { + cin >> std::get<0>(edges[i]) >> std::get<1>(edges[i]) >> std::get<2>(edges[i]); + } + + while (l <= q) { + bool flag = false; + + for (int i = 0; i <= k; i++) { + int r = std::min(l + (1 << i), q); + if (check(l, r)) { + int ql = i ? l + (1 << i - 1) : 0, + qr = l + (1 << i), + res = qr; + + while (ql <= qr) { + int mid = (ql + qr) >> 1; + if (check(l, mid)) { + qr = mid - 1; + res = mid; + } else { + ql = mid + 1; + } + } + + ans.emplace_back(res); + l = res + 1; + flag = true; + + break; + } + + if (r == q) break; + } + + if (!flag) break; + } + + cout << ans.size() << endl; + for (int x : ans) cout << x << ' '; + cout << endl; + + return 0; +} diff --git a/S2OJ/1733/data/ex_path1.ans b/S2OJ/1733/data/ex_path1.ans new file mode 100644 index 00000000..bb9520ed --- /dev/null +++ b/S2OJ/1733/data/ex_path1.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cefe717e1d35a2001a1d0a84a3d9530a14e5a87e1690c7d9b4a1c68538c805bc +size 6 diff --git a/S2OJ/1733/data/ex_path1.in b/S2OJ/1733/data/ex_path1.in new file mode 100644 index 00000000..05a74c1a --- /dev/null +++ b/S2OJ/1733/data/ex_path1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d2c5efab71ec3d2752787890403f8af43457b1b1f7be0f9895c030269b94e2a7 +size 30 diff --git a/S2OJ/1733/data/ex_path2.ans b/S2OJ/1733/data/ex_path2.ans new file mode 100644 index 00000000..9b75c8b6 --- /dev/null +++ b/S2OJ/1733/data/ex_path2.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b299db3a3f700c8d34cfdbac14e8496cee0bb32791f1a2c60e6b06f35ee1c095 +size 35 diff --git a/S2OJ/1733/data/ex_path2.in b/S2OJ/1733/data/ex_path2.in new file mode 100644 index 00000000..aa273897 --- /dev/null +++ b/S2OJ/1733/data/ex_path2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6a5f841c8cd830ae9b8811a38da94647de8d39af8e17dfdc6b20c003147db510 +size 37899 diff --git a/S2OJ/1733/data/ex_path3.ans b/S2OJ/1733/data/ex_path3.ans new file mode 100644 index 00000000..6fbbc7d1 --- /dev/null +++ b/S2OJ/1733/data/ex_path3.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:74eaffc8d1fd7567b70b2bb9682d0b5f4c480f9668e5c9a49cef6d5ffccad0f8 +size 35 diff --git a/S2OJ/1733/data/ex_path3.in b/S2OJ/1733/data/ex_path3.in new file mode 100644 index 00000000..f39cd189 --- /dev/null +++ b/S2OJ/1733/data/ex_path3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:46b74286abdb5f3bea5122838dfa2226f07ae5d7ceaa83a563f0ab1953827b4a +size 4932773 diff --git a/S2OJ/1733/data/path1.ans b/S2OJ/1733/data/path1.ans new file mode 100644 index 00000000..9e3fdfad --- /dev/null +++ b/S2OJ/1733/data/path1.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:909f8993b97522d87377826c7fed8e86fe10046f7d0f99e5e2bcfff72203df08 +size 10 diff --git a/S2OJ/1733/data/path1.in b/S2OJ/1733/data/path1.in new file mode 100644 index 00000000..b28229e5 --- /dev/null +++ b/S2OJ/1733/data/path1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e31507f790bc3da2a7037cdbb1b219e1d67b3ebfea57355e93f5c4a86964e3ef +size 463 diff --git a/S2OJ/1733/data/path10.ans b/S2OJ/1733/data/path10.ans new file mode 100644 index 00000000..850606ec --- /dev/null +++ b/S2OJ/1733/data/path10.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b2ae42c75694e99e5c2e6fe7948468cdbef0c15a653c8ecd0a8473611ac637ff +size 544 diff --git a/S2OJ/1733/data/path10.in b/S2OJ/1733/data/path10.in new file mode 100644 index 00000000..2a4b8d98 --- /dev/null +++ b/S2OJ/1733/data/path10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9ddba118385fc4cb3f9f1e276f9b5c9a81f38dcecd79662376cffca7bb7ff70a +size 4709581 diff --git a/S2OJ/1733/data/path2.ans b/S2OJ/1733/data/path2.ans new file mode 100644 index 00000000..63b48549 --- /dev/null +++ b/S2OJ/1733/data/path2.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fb5915a3c2f9896e80aba05c3b8e0293cf771dba1f5d83a8f96f17122b00e41e +size 5 diff --git a/S2OJ/1733/data/path2.in b/S2OJ/1733/data/path2.in new file mode 100644 index 00000000..d37a216e --- /dev/null +++ b/S2OJ/1733/data/path2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:37ed2f04065a940f82305f25ff4d292dca005fecd520fb2d6877aafe2bea5f62 +size 1082 diff --git a/S2OJ/1733/data/path3.ans b/S2OJ/1733/data/path3.ans new file mode 100644 index 00000000..fe08e03a --- /dev/null +++ b/S2OJ/1733/data/path3.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f8dbc839c544110b8d2c2881b8c6de7368d2ff75f3f7157e75be47d065f9a457 +size 18 diff --git a/S2OJ/1733/data/path3.in b/S2OJ/1733/data/path3.in new file mode 100644 index 00000000..69487a6b --- /dev/null +++ b/S2OJ/1733/data/path3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:70659c164e452e2cb2a49d6dfe290d59c4ee23079956224f86b16aca5d1cb6e6 +size 12198 diff --git a/S2OJ/1733/data/path4.ans b/S2OJ/1733/data/path4.ans new file mode 100644 index 00000000..6d183ddb --- /dev/null +++ b/S2OJ/1733/data/path4.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ee765ed3d34efe975de4198961f0c94fc3a7d2eb7ed7ba3294892ab19f361849 +size 231 diff --git a/S2OJ/1733/data/path4.in b/S2OJ/1733/data/path4.in new file mode 100644 index 00000000..41d48329 --- /dev/null +++ b/S2OJ/1733/data/path4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b6f6f65e94048cc4481cd8ac6e961c20548422a44203b39c546262430bff7b04 +size 31608 diff --git a/S2OJ/1733/data/path5.ans b/S2OJ/1733/data/path5.ans new file mode 100644 index 00000000..fdc679a2 --- /dev/null +++ b/S2OJ/1733/data/path5.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ad194b8470ad17ea1ccd77ca45ad3720f6557bd261666f48db3dbe47f63db3d1 +size 36 diff --git a/S2OJ/1733/data/path5.in b/S2OJ/1733/data/path5.in new file mode 100644 index 00000000..8e2eb491 --- /dev/null +++ b/S2OJ/1733/data/path5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:649aeb3e2ef63981adea553feedb065a48f31cf74c626ab53099905b124cf6be +size 4933318 diff --git a/S2OJ/1733/data/path6.ans b/S2OJ/1733/data/path6.ans new file mode 100644 index 00000000..c3bb5ec2 --- /dev/null +++ b/S2OJ/1733/data/path6.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fafa6da2bc5ee49da56628144c61aa6e49bffe86d4422e3e4a4512028bcb9d83 +size 22 diff --git a/S2OJ/1733/data/path6.in b/S2OJ/1733/data/path6.in new file mode 100644 index 00000000..dee5e23d --- /dev/null +++ b/S2OJ/1733/data/path6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a9fba30176cd3ee39c96fa78b95591764700bd1dc211a2f2e219789728770f50 +size 4185557 diff --git a/S2OJ/1733/data/path7.ans b/S2OJ/1733/data/path7.ans new file mode 100644 index 00000000..5c192515 --- /dev/null +++ b/S2OJ/1733/data/path7.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b63fc758dd2db7faeb0dbac78d7b09d448018fce52530daaf8bea0cd8fd3eef7 +size 1034 diff --git a/S2OJ/1733/data/path7.in b/S2OJ/1733/data/path7.in new file mode 100644 index 00000000..15ee284b --- /dev/null +++ b/S2OJ/1733/data/path7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cd95b1afc130ae736259c790a8b442cd5bce1c0201eacff977cb3387ba4bbdc8 +size 4123633 diff --git a/S2OJ/1733/data/path8.ans b/S2OJ/1733/data/path8.ans new file mode 100644 index 00000000..486461c4 --- /dev/null +++ b/S2OJ/1733/data/path8.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8c0c8fab9484da6d7b124e2a8de246466196294f4d48f0c8b4e3cf88698f8fb6 +size 1001 diff --git a/S2OJ/1733/data/path8.in b/S2OJ/1733/data/path8.in new file mode 100644 index 00000000..38932ed7 --- /dev/null +++ b/S2OJ/1733/data/path8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4c820c2235f1c00431084be08adcb8df8d26f54a526e0b688370c1d6b2b73e32 +size 4235909 diff --git a/S2OJ/1733/data/path9.ans b/S2OJ/1733/data/path9.ans new file mode 100644 index 00000000..6f21d50f --- /dev/null +++ b/S2OJ/1733/data/path9.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:710a3d6c1ed0f4d49b91a2a5cf6891b6249fc8be6ae370a25be1f23441005dc0 +size 9814 diff --git a/S2OJ/1733/data/path9.in b/S2OJ/1733/data/path9.in new file mode 100644 index 00000000..b8470ece --- /dev/null +++ b/S2OJ/1733/data/path9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f2a611b3f924845fff2dc34488d74bb04bf3f011f983a034b332b0afafc6c9df +size 4142725 diff --git a/S2OJ/1733/data/problem.conf b/S2OJ/1733/data/problem.conf new file mode 100644 index 00000000..a5dcdddb --- /dev/null +++ b/S2OJ/1733/data/problem.conf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ef8b7755c534c8e0a118448f916077fd2ee3245f6fc06c4bc47ee5e2c7c8c59e +size 177