提交记录 27362
提交时间 |
评测时间 |
2024-11-18 11:54:46 |
2024-11-18 11:54:54 |
#include <algorithm>
#include <array>
#include <vector>
void sort(unsigned* a, int n) {
constexpr int BASE_WIDTH = 16;
constexpr unsigned BASE = 1 << BASE_WIDTH;
auto cursors = std::array<std::array<int, BASE>, 2>();
for (int i = 0; i < n; i++) {
cursors[0][a[i] & (BASE - 1)]++;
cursors[1][(a[i] >> BASE_WIDTH) & (BASE - 1)]++;
}
for (int iter = 0; iter < 2; iter++) {
int prefix_offset = 0;
for (unsigned v = 0; v < BASE; v++) {
std::swap(prefix_offset, cursors[iter][v]);
prefix_offset += cursors[iter][v];
}
}
auto buffer = new unsigned[n];
for (int i = 0; i < n; i++) {
buffer[cursors[0][a[i] & (BASE - 1)]++] = a[i];
}
for (int i = 0; i < n; i++) {
a[cursors[1][buffer[i] >> BASE_WIDTH]++] = buffer[i];
}
delete[] buffer;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 1.599 ms | 1 MB + 288 KB | Accepted | Score: 34 | 显示更多 |
Testcase #2 | 2.938 s | 763 MB + 472 KB | Accepted | Score: 33 | 显示更多 |
Testcase #3 | 3 s | 1526 MB + 404 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-11-23 16:22:10 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠