70,求助

P2471 [SCOI2007] 降雨量

估计有不止一个地方有小问题,我认为其中一个地方是第 $60$ 行 `y = lower_bound(ye + 1, ye + n + 1, y2) - ye;` 应改为 `y = lower_bound(ye + 1, ye + n + 1, y2, less<int>()) - ye;`,$x$ 要取第一个大于等于的但是 $y$ 要取第一个小于等于的,以保证 `calc()` 的正确性。 这是我的AC代码的主程序,可以参考一下: ``` int main() { read(n); for (int i = 1; i <= n; i++) read(rain[i].first), read(rain[i].second); build(1, 1, n); read(m); while (m--) { int yeary, yearx; read(yeary), read(yearx); int posx = binary2(yearx), posy = binary1(yeary); bool isx = rain[posx].first == yearx, isy = rain[posy].first == yeary; int numx = rain[posx].second, numy = rain[posy].second; // Three basic necessary conditions: numx <= numy; query() < numx; query() < numy. if (isx && isy) { if (numx > numy) { fwrite("false\n", 1, 6, stdout); continue; } if (posy + 1 <= posx - 1 && query(1, posy + 1, posx - 1) >= numx) { fwrite("false\n", 1, 6, stdout); continue; } if (posx - posy != yearx - yeary) { fwrite("maybe\n", 1, 6, stdout); continue; } fwrite("true\n", 1, 5, stdout); continue; } if (isx) { if (posy + 1 <= posx - 1 && query(1, posy + 1, posx - 1) >= numx) { fwrite("false\n", 1, 6, stdout); continue; } fwrite("maybe\n", 1, 6, stdout); continue; } if (isy) { if (posy + 1 <= posx - 1 && query(1, posy + 1, posx - 1) >= numy) { fwrite("false\n", 1, 6, stdout); continue; } fwrite("maybe\n", 1, 6, stdout); continue; } fwrite("maybe\n", 1, 6, stdout); } return 0; } ```
by hzlqwq @ 2023-04-29 22:42:32


猜测有可能是分类讨论的情况数多了或者少了,可以再看看。
by hzlqwq @ 2023-04-29 22:45:18


|