提交记录 13769
| 提交时间 |
评测时间 |
| 2020-08-09 21:02:36 |
2020-08-09 21:02:37 |
#include <algorithm>
#pragma GCC optimize("Ofast", 3, "inline")
typedef unsigned int u32;
void sort(unsigned *a, int n) {
u32 cnt[256];
u32 *b = new u32[n];
u32 ps = 0;
memset(cnt, 0, sizeof cnt);
for (int i = 0; i < n; ++i) ++cnt[(a[i] >> ps) & 0xff];
for (int i = 1; i < 256; ++i) cnt[i] += cnt[i - 1];
for (int i = n - 1; ~i; --i) b[--cnt[(a[i] >> ps) & 0xff]] = a[i];
std::swap(a, b);
ps = 8;
memset(cnt, 0, sizeof cnt);
for (int i = 0; i < n; ++i) ++cnt[(a[i] >> ps) & 0xff];
for (int i = 1; i < 256; ++i) cnt[i] += cnt[i - 1];
for (int i = n - 1; ~i; --i) b[--cnt[(a[i] >> ps) & 0xff]] = a[i];
std::swap(a, b);
ps = 16;
memset(cnt, 0, sizeof cnt);
for (int i = 0; i < n; ++i) ++cnt[(a[i] >> ps) & 0xff];
for (int i = 1; i < 256; ++i) cnt[i] += cnt[i - 1];
for (int i = n - 1; ~i; --i) b[--cnt[(a[i] >> ps) & 0xff]] = a[i];
std::swap(a, b);
ps = 24;
memset(cnt, 0, sizeof cnt);
for (int i = 0; i < n; ++i) ++cnt[(a[i] >> ps) & 0xff];
for (int i = 1; i < 256; ++i) cnt[i] += cnt[i - 1];
for (int i = n - 1; ~i; --i) b[--cnt[(a[i] >> ps) & 0xff]] = a[i];
std::swap(a, b);
}
| Compilation | N/A | N/A | Compile Error | Score: N/A | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2026-03-23 18:58:41 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠