提交记录 21720
用户 |
题目 |
状态 |
得分 |
用时 |
内存 |
语言 |
代码长度 |
user1 |
1001. 测测你的排序 |
Accepted |
100 |
1.061 s |
781296 KB |
C++ |
1.13 KB |
提交时间 |
评测时间 |
2024-05-03 23:46:31 |
2024-05-03 23:46:37 |
#pragma GCC optimize("Ofast,inline,unroll-loops")
#include <bits/stdc++.h>
#include <immintrin.h>
using namespace std;
const int n = 1e8;
template<class T>
void F(uint* __restrict__ buc, uint* __restrict__ a, uint* __restrict__ b, T lambda) {
for (int i = 0; i < n; i += 16) {
_mm_prefetch(&a[i + 256], _MM_HINT_NTA);
#pragma GCC unroll 16
for (int j = 0; j < 16; j++)
b[buc[lambda(a[i + j])]++] = a[i + j];
}
}
void sort(uint* a, int __n) {
uint buc[4][512] = {};
uint* b = (uint*)malloc(n * sizeof(uint));
for (int i = 0; i < n; i++) {
buc[1][a[i] >> 5 & 511]++;
buc[2][a[i] >> 14 & 511]++;
buc[3][a[i] >> 23]++;
}
for (int k = 0; k < 4; k++) {
uint32_t offset = 0;
for (int i = 0; i < 512; i++)
swap(buc[k][i], offset), offset += buc[k][i];
}
F(buc[1], a, b, [](uint x) { return x >> 5 & 511; });
F(buc[2], b, a, [](uint x) { return x >> 14 & 511; });
F(buc[3], a, b, [](uint x) { return x >> 23; });
for (int i = 0; i<n; ++i) {
int j = i, x = b[i];
while (j && a[j-1]>x) a[j]=a[j-1], --j;
a[j] = x;}
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 1.061 s | 762 MB + 1008 KB | Accepted | Score: 100 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2025-07-18 06:59:26 | Loaded in 0 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠