Cod sursa(job #2057996)
Utilizator | ------ neth | Data | 4 noiembrie 2017 23:36:00 |
---|---|---|---|
Problema | Radix Sort | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <bits/stdc++.h>
#define V v[i]
#define R(x,y,z)for(i=x;i!=y;i+=z)
int v[10000000],w[10000000],x[16],n,i,b,c;main(){std::ifstream("radixsort.in")>>n>>b>>V>>c;R(1,n,1)V=(1LL*b*v[i-1]+v[0])%c;R(0,32,4){b=i;memset(x,0,64);R(0,n,1)++x[V>>b&15];R(1,16,1)x[i]+=x[i-1];R(n-1,-1,-1)w[--x[V>>b&15]]=V;std::swap(v,w);i=b;}std::ofstream f("radixsort.out");R(0,n,10)f<<V<<' ';}