标签:tin getchar stdout sig script temp line amp fine
排序一组1e8的数列并输出
数列大小是32为的无符号整形
拆2的8次方基数排序即可
%:pragma GCC optimize("Ofast,inline,unroll-loops")
%:pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define R register
#define I inline
using namespace std;
template<class T>
I void rea(T &x)
{
char ch=getchar();int f(0);x = 0;
while(!isdigit(ch)) {f|=ch=='-';ch=getchar();}
while(isdigit(ch)) {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
x = f?-x:x;
}
const int N = 100000005;
unsigned int n, seed, a[N], b[N], bucket[256];
I unsigned int Rand()
{
seed^=seed<<5, seed^=seed>>7, seed^=seed<<15;
return seed;
}
I unsigned int get(unsigned int x, unsigned int d)
{
return ((x>>8*(d-1))&255);
}
I void sorting()
{
unsigned int *x(a), *y(b);
for(R int d = 1; d <= 4; ++d)
{
for(R int i = 0; i < 256; ++i) bucket[i] = 0;
for(R int i = 1; i <= n; ++i) bucket[get(x[i], d)]++;
for(R int i = 1; i < 256; ++i) bucket[i] = bucket[i-1]+bucket[i];
for(R int i = n; i >= 1; --i) y[bucket[get(x[i], d)]--] = x[i];
swap(x, y);
}
}
int main()
{
freopen("sorting.in","r",stdin);
freopen("sorting.out","w",stdout);
rea(n), rea(seed);
for(R int i = 1; i <= n; ++i) a[i] = Rand();
sorting();
unsigned int res = 0;
for(R int i = 1; i <= n; ++i) res ^= a[i]+Rand();
cout<<res<<endl;
return 0;
}
标签:tin getchar stdout sig script temp line amp fine
原文地址:https://www.cnblogs.com/heanda/p/12404290.html