为什么加上标记优化反而全T

P1629 邮递员送信

@[FallingSakura](/user/773503) 你这样的话可能会导致全部弹出q访问top时就T了。
by WhisperingWillow @ 2023-07-08 08:45:14


@[jordendujunrui](/user/820807) 堆为空时访问top的返回值righ不应该是`false`然后退出循环嘛?
by Falling_Sakura @ 2023-07-08 17:08:26


假如堆里都访问过就会进行清空,而这个时候再访问堆顶就会导致 RE 所以要这样写: ```cpp while(!heap.empty()) { point now=heap.top(); heap.pop(); if(righ[now.p]) continue; ``` 此帖结。
by Falling_Sakura @ 2023-08-19 04:26:07


|