#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define FOR(i,j,k) for(int i=j; i<=k; ++i)
#define ROF(i,j,k) for(int i=j; i>=k; --i)
#define ud unsigned
ud b[134217728], c[256];
const int g = 255;
void sort (ud *a, int n) {
std::iota (b, b+n, 0);
std::fill (c, c+g+1, 0);
FOR(i,0,n-1) ++ c[a[i]&g];
FOR(i,1,g) c[i] += c[i-1];
ROF(i,n-1,0) b[-- c[a[i]&g]] = a[i];
std::fill (c, c+g+1, 0);
FOR(i,0,n-1) ++ c[b[i]>>8&g];
FOR(i,1,g) c[i] += c[i-1];
ROF(i,n-1,0) a[-- c[b[i]>>8&g]] = b[i];
std::fill (c, c+g+1, 0);
FOR(i,0,n-1) ++ c[a[i]>>16&g];
FOR(i,1,g) c[i] += c[i-1];
ROF(i,n-1,0) b[-- c[a[i]>>16&g]] = a[i];
std::fill (c, c+g+1, 0);
FOR(i,0,n-1) ++ c[b[i]>>24&g];
FOR(i,1,g) c[i] += c[i-1];
ROF(i,n-1,0) a[-- c[b[i]>>24&g]] = b[i];
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 16.243 s | 1024 MB + 32 KB | Accepted | Score: 100 | 显示更多 |