提交记录 13770
提交时间 |
评测时间 |
2020-08-09 21:03:03 |
2020-08-09 21:03:08 |
#include<bits/stdc++.h>
#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 OK | Score: N/A | 显示更多 |
Testcase #1 | 1.064 ms | 808 KB | Accepted | Score: 34 | 显示更多 |
Testcase #2 | 1.147 s | 762 MB + 992 KB | Accepted | Score: 33 | 显示更多 |
Testcase #3 | 2.296 s | 1525 MB + 928 KB | Accepted | Score: 33 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-11-22 06:15:29 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠