提交记录 28012
提交时间 |
评测时间 |
2025-03-13 18:52:30 |
2025-03-13 18:52:36 |
#include <algorithm>
#include <cstdlib>
#include <numeric>
#include <vector>
using u32 = unsigned;
template<class KeyFunc>
void counting_sorted(u32 *first, size_t n, u32 *dest, KeyFunc key) {
using std::for_each_n;
using std::exclusive_scan;
size_t *rank = (size_t *) calloc(65536, sizeof(size_t));
for_each_n(first, n, [&](u32 elem) {
++rank[key(elem)];
});
exclusive_scan(rank, rank + 65536, rank, 0);
for_each_n(first, n, [&](u32 elem) {
dest[rank[key(elem)]++] = elem;
});
free(rank);
}
void sort(u32 *arr, int n) {
u32 *tmp = (u32 *) malloc(n * sizeof(u32));
counting_sorted(arr, n, tmp, [](u32 elem) { return elem & 65535; });
counting_sorted(tmp, n, arr, [](u32 elem) { return (elem >> 16) & 65535; });
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 2.818 s | 763 MB + 464 KB | Accepted | Score: 100 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2025-04-02 21:44:33 | Loaded in 0 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠