提交记录 8558


用户 题目 状态 得分 用时 内存 语言 代码长度
MashPlant 1001. 测测你的排序 Accepted 100 862.562 ms 781260 KB C++ 1.00 KB
提交时间 评测时间
2019-02-25 14:03:00 2020-08-01 01:21:13
#include <cstdio>
#include <cstring>
unsigned aux[100000005];

void sort(unsigned *a, int n) {
  const int U = 256;
  int cnt[U];
  memset(cnt, 0, sizeof cnt);
  for (int i = 0; i < n; ++i)
    ++cnt[a[i] & U - 1];
  for (int i = 1; i < U; ++i)
    cnt[i] += cnt[i - 1];
  for (int i = n - 1; i >= 0; --i)
    aux[--cnt[a[i] & U - 1]] = a[i];
  memset(cnt, 0, sizeof cnt);
  for (int i = 0; i < n; ++i)
    ++cnt[aux[i] >> 8 & U - 1];
  for (int i = 1; i < U; ++i)
    cnt[i] += cnt[i - 1];
  for (int i = n - 1; i >= 0; --i)
    a[--cnt[aux[i] >> 8 & U - 1]] = aux[i];
  memset(cnt, 0, sizeof cnt);
  for (int i = 0; i < n; ++i)
    ++cnt[a[i] >> 16 & U - 1];
  for (int i = 1; i < U; ++i)
    cnt[i] += cnt[i - 1];
  for (int i = n - 1; i >= 0; --i)
    aux[--cnt[a[i] >> 16 & U - 1]] = a[i];
  memset(cnt, 0, sizeof cnt);
  for (int i = 0; i < n; ++i)
    ++cnt[aux[i] >> 24 & U - 1];
  for (int i = 1; i < U; ++i)
    cnt[i] += cnt[i - 1];
  for (int i = n - 1; i >= 0; --i)
    a[--cnt[aux[i] >> 24 & U - 1]] = aux[i];
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #1862.562 ms762 MB + 972 KBAcceptedScore: 100


Judge Duck Online | 评测鸭在线
Server Time: 2024-11-23 23:54:15 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠