From e021305f1354c994110456672a6bc4b9a2d86a6b Mon Sep 17 00:00:00 2001 From: hanyixuanten <105723997+hanyixuanten@users.noreply.github.com> Date: Tue, 25 Aug 2026 18:53:09 +0800 Subject: [PATCH] new file: P11232.cpp --- P11232.cpp | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 P11232.cpp diff --git a/P11232.cpp b/P11232.cpp new file mode 100644 index 0000000..7757b2b --- /dev/null +++ b/P11232.cpp @@ -0,0 +1,110 @@ +#include +using namespace std; +typedef long long ll; +struct node +{ + ll d, v, a; + int l, r; // 超速时对应的测速仪区间下标 + bool over; // 是否超速 +} car[100005]; + +bool cmp(const node &x, const node &y) +{ + return x.r < y.r; +} +ll p[100005]; +int main() +{ + int T; + scanf("%d", &T); + while (T--) + { + int n, m; + ll L, V; + scanf("%d%d%lld%lld", &n, &m, &L, &V); + for (int i = 1; i <= n; ++i) + { + scanf("%lld%lld%lld", &car[i].d, &car[i].v, &car[i].a); + car[i].over = false; + } + for (int i = 1; i <= m; ++i) + scanf("%lld", &p[i]); + sort(p + 1, p + m + 1); + int ans = 0; + for (int i = 1; i <= n; ++i) + { + ll d = car[i].d, v0 = car[i].v, a = car[i].a; + if (a == 0) + { + if (v0 > V) + { + int idx = lower_bound(p + 1, p + m + 1, d) - p; + if (idx <= m) + { + car[i].over = true; + car[i].l = idx; + car[i].r = m; + } + } + } + else if (a > 0) + { + int idx; + if (v0 > V) + { + idx = lower_bound(p + 1, p + m + 1, d) - p; + } + else + { + ll x = d + (V * V - v0 * v0) / (2 * a) + 1; + idx = lower_bound(p + 1, p + m + 1, x) - p; + } + if (idx <= m) + { + car[i].over = true; + car[i].l = idx; + car[i].r = m; + } + } + else + { // a < 0 + if (v0 > V) + { + int L = lower_bound(p + 1, p + m + 1, d) - p; + ll num = v0 * v0 - V * V; + ll den = -2 * a; + ll fn = d + (num + den - 1) / den; + int R = lower_bound(p + 1, p + m + 1, fn) - p - 1; + if (L <= m && L <= R) + { + car[i].over = true; + car[i].l = L; + car[i].r = R; + } + } + } + if (car[i].over) + ans++; + } + vector over; + for (int i = 1; i <= n; ++i) + { + if (car[i].over) + over.push_back(car[i]); + } + sort(over.begin(), over.end(), cmp); + int choose = 0; + int last = -1; + for (auto &now : over) + { + if (now.l > last) + { + last = now.r; + choose++; + } + } + + printf("%d %d\n", ans, m - choose); + } + return 0; +} \ No newline at end of file