提交记录 17772
提交时间 |
评测时间 |
2022-07-06 09:49:57 |
2022-07-06 09:50:04 |
#include <bits/stdc++.h>
namespace Radix_Sort{
const int B=16,M=(1<<B)-1,N=100000000,W=32;
unsigned cnt[1<<B],t[N];
template<typename T=int>inline void radix_sort(T*_begin_iter,T*_end_iter){
int n=_end_iter-_begin_iter;
unsigned*b=t;
for(int i=0;i<W;i+=B){
for(int j=0;j<=M;j++)cnt[j]=0;
for(int j=0;j<n;j++)++cnt[(_begin_iter[j]>>i)&M];
for(int s=0,j=0;j<=M;j++)s+=cnt[j],cnt[j]=s-cnt[j];
for(int j=0;j<n;j++)b[cnt[(_begin_iter[j]>>i)&M]++]=_begin_iter[j];
std::swap(_begin_iter,b);
}
}
}
using Radix_Sort::radix_sort;
void sort(unsigned *a, int n) {
radix_sort<unsigned>(a, a + n);
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 2.369 s | 763 MB + 228 KB | Accepted | Score: 100 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-11-23 23:57:25 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠