提交记录 30447
| 提交时间 |
评测时间 |
| 2026-08-12 21:57:22 |
2026-08-12 21:57:28 |
#pragma GCC target("avx2")
typedef unsigned long U;
#ifndef N
#define N (1U << 27)
#endif
#define HIGH_BUCKETS 256U
#define LOW_BUCKETS 4096U
static unsigned work[N] __attribute__((aligned(64)));
static unsigned high_next[HIGH_BUCKETS];
static unsigned high_end[HIGH_BUCKETS];
static unsigned low_position[LOW_BUCKETS];
static unsigned middle_position[LOW_BUCKETS];
static U duck;
U getauxval(U key) { return duck; }
static void partition_high_byte(unsigned *a) {
for (unsigned i = 0; i < N; ++i) ++high_end[a[i] >> 24];
unsigned sum = 0;
for (unsigned digit = 0; digit < HIGH_BUCKETS; ++digit) {
unsigned amount = high_end[digit];
high_next[digit] = sum;
sum += amount;
high_end[digit] = sum;
}
for (unsigned bucket = 0; bucket < HIGH_BUCKETS; ++bucket) {
while (high_next[bucket] < high_end[bucket]) {
unsigned position = high_next[bucket];
unsigned value = a[position];
unsigned digit = value >> 24;
while (digit != bucket) {
unsigned target = high_next[digit]++;
unsigned displaced = a[target];
a[target] = value;
value = displaced;
digit = value >> 24;
}
a[position] = value;
high_next[bucket] = position + 1;
}
}
}
void sort(unsigned *a, int n) {
(void)n;
partition_high_byte(a);
unsigned begin = 0;
for (unsigned bucket = 0; bucket < HIGH_BUCKETS; ++bucket) {
unsigned end = high_end[bucket];
__builtin_memset(low_position, 0, sizeof(low_position));
__builtin_memset(middle_position, 0, sizeof(middle_position));
for (unsigned i = begin; i < end; ++i) {
unsigned value = a[i];
++low_position[value & 4095U];
++middle_position[(value >> 12) & 4095U];
}
unsigned sum0 = begin, sum1 = begin;
for (unsigned digit = 0; digit < LOW_BUCKETS; ++digit) {
unsigned amount0 = low_position[digit];
unsigned amount1 = middle_position[digit];
low_position[digit] = sum0;
middle_position[digit] = sum1;
sum0 += amount0;
sum1 += amount1;
}
for (unsigned i = begin; i < end; ++i) {
unsigned value = a[i];
work[low_position[value & 4095U]++] = value;
}
for (unsigned i = begin; i < end; ++i) {
unsigned value = work[i];
a[middle_position[(value >> 12) & 4095U]++] = value;
}
begin = end;
}
}
__attribute__((noreturn))
void __libc_start_main(int (*entry)(int, char **, char **), int argc,
char **argv) {
U *aux = (U *)(argv + 2);
while (aux[0] != 0x6b637564UL) aux += 2;
duck = aux[1]; entry(argc, argv, (char **)0);
__asm__ volatile("mov $60,%%eax;xor %%edi,%%edi;syscall"
::: "rax", "rdi", "rcx", "r11", "memory");
__builtin_unreachable();
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 2.233 s | 1024 MB + 40 KB | Accepted | Score: 100 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2026-09-12 13:30:42 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠