### 解决办法
将单关键字排序改为双关键字排序,当 $x$ 或 $y$(取决于实现方式)相等时,按负责加的线段在前,负责减的线段在后的顺序排序:
原版 WA 代码:
```cpp
struct Line
{
int x, y1, y2, type;
inline bool operator<(const Line &a) const
{
return x < a.x;
}
} line[N];
```
改后 AC 代码:
```cpp
struct Line
{
int x, y1, y2, type;
inline bool operator<(const Line &a) const
{
if (x ^ a.x)
return x < a.x;
return type > a.type;
}
} line[N];
```
by hzlqwq @ 2023-08-08 23:31:59
大佬tql,感谢感谢
by A_Little_BadBoy @ 2024-05-04 15:34:56