为啥sort能用

P1223 排队接水

**说明/提示** sort是可以的
by Nopain @ 2022-05-04 10:56:21


@[jardine](/user/688200) 见题目下方的提示说明 嘻嘻,我就是用sort过的
by YUN_0120 @ 2022-05-04 10:59:23


`stable_sort` 应该是可以的?
by happybob @ 2022-05-04 11:01:17


@[sunset1028](/user/376149) 我看到这个提示了,所以我才想问,为什么可以。
by jardine @ 2022-05-04 11:09:26


@[jardine](/user/688200) 考虑结构体排序,第一关键字是大小,第二关键字是编号?
by Alex_wcq @ 2022-05-04 11:10:27


题解代码基本上都用了编号作为第二关键字
by Alex_wcq @ 2022-05-04 11:12:13


@[jardine](/user/688200) sort内部是使用各种排序算法组成的,有 quickSort 也有 mergeSort,数据量较小的时候甚至有 insertSort,根本不可能保证稳定性。所以按理来说 sort 应该不可以。
by jardine @ 2022-05-04 11:13:20


@[Alex_wcq](/user/482049) 双关键字排序应该没问题。
by jardine @ 2022-05-04 11:18:08


@[jardine](/user/688200) ```cpp const bool operator<(const node& x,const node& y)const{ return(x.s==y.s?x.id<y.id:x.s<y.s); } ```
by Etinorally @ 2022-05-04 11:25:47


类似于这样的双关键字就可以了
by Etinorally @ 2022-05-04 11:26:15


| 下一页