版本比较
P14222题解
正文
增加 8 行删除 5 行
12343465678910111212131415161724 行未改动424344454546474849507 行未改动585960616263萌新蒟蒻 qwq。
一道点和区间的问题。不过这道题似乎真的很少见 awa。 一道二分题,按时间顺序。 一道点和区间的问题。不过这道题似乎真的很少见 awa。一道二分题,按时间顺序。
`l - tmp`是端点机器人的左区间, `r + tmp` 是端点机器人的右区间, `a[i - 1].second - tmp` 是区间机器人的左区间, `a[i - 1].second + tmp` 是区间机器人的右区间。 两个 $bool$ 是判断可不可行。$(t_i - t_{i - 1}) \times x$ 是上个金币出现时间到下个金币出现时间能移动的最大距离,$l - tmp$ 是端点机器人的左区间,$r + tmp$ 是端点机器人的右区间,$c_{i - 1} - tmp$ 是区间机器人的左区间,$c_{i - 1} + tmp$ 是区间机器人的右区间。$c_i \ge c_{i - 1} - tmp $ 且 $c_i \le c_{i - 1} + tmp$ 是端点机器人能不能捡,$l - tmp \le c_i$ 且 $c_i \le r + tmp$ 是区间机器人能不能捡,这两个都算距离。
注:端点机器人是上一个捡的机器人,区间机器人是上一个没捡的机器人,代码中的 `a[i].first` 是题解中的 $t_i$,`a[i].second` 是题解中的 $c_i$。
详见注释。
[记录](https://www.luogu.com.cn/record/240541515)
$AC$ $code$:AC code :```cpp#include <bits/stdc++.h>#define int long long // 不开long long见祖宗?using namespace std;24 行未改动 return 1;}signed main() { scanf("%lld", &t); while (t--) { while (t--) { l = 0, r = INF; scanf("%lld", &n); for (int i = 1; i <= n; i++) scanf("%lld%lld", &a[i].first, &a[i].second); while (l < r) { // 朴素的二分7 行未改动 return 0;}```p.s.:洛谷重现赛的首 A。
管理员大大求过!