【发布时间】:2020-03-17 22:23:05
【问题描述】:
struct node {
int L, R, i;
}q[N];
bool cmp(node x, node y) {
if(x.L/BLOCK != y.L/BLOCK) {
// different blocks, so sort by block.
return x.L/BLOCK < y.L/BLOCK;
}
// same block, so sort by R value
return x.R < y.R;
}
sort(q, q + m, cmp);
其中 m 是 q 数组的大小。我想知道如何在 python 中实现上述 c++ 代码,即基于函数作为第三个参数进行比较。
【问题讨论】:
-
到目前为止你做了什么?
-
什么是 x.L/BLOCK
标签: python