提交记录 18731


用户 题目 状态 得分 用时 内存 语言 代码长度
iMMIQ 1001. 测测你的排序 Time Limit Exceeded 0 5 s 781292 KB C++ 1.11 KB
提交时间 评测时间
2022-12-05 22:05:24 2022-12-05 22:05:34
#include <bits/stdc++.h>

void sort(unsigned *a, int n) {
  std::vector<unsigned> cnt1(256), cnt2(256), cnt3(256), cnt4(256);
  std::fill(cnt1.begin(), cnt1.end(), 0);
  std::fill(cnt2.begin(), cnt2.end(), 0);
  std::fill(cnt3.begin(), cnt3.end(), 0);
  std::fill(cnt4.begin(), cnt4.end(), 0);
  for (int i = 0; i < n; i++) {
    cnt1[a[i] & 255]++;
    cnt2[(a[i] >> 8) & 255]++;
    cnt3[(a[i] >> 16) & 255]++;
    cnt4[a[i] >> 24]++;
  }
  for (int i = 1; i < 256; i++) {
    cnt1[i] += cnt1[i - 1];
    cnt2[i] += cnt2[i - 1];
    cnt3[i] += cnt3[i - 1];
    cnt4[i] += cnt4[i - 1];
  }

  std::vector<unsigned> pos(n);
  for (int i = n - 1; i >= 0; i--) pos[--cnt1[a[i] & 255]] = i;
  for (int i = 0; i < n; i++) std::swap(a[i], a[pos[i]]);

  for (int i = n - 1; i >= 0; i--) pos[--cnt2[(a[i] >> 8) & 255]] = i;
  for (int i = 0; i < n; i++) std::swap(a[i], a[pos[i]]);

  for (int i = n - 1; i >= 0; i--) pos[--cnt3[(a[i] >> 16) & 255]] = i;
  for (int i = 0; i < n; i++) std::swap(a[i], a[pos[i]]);

  for (int i = n - 1; i >= 0; i--) pos[--cnt4[a[i] >> 24]] = i;
  for (int i = 0; i < n; i++) std::swap(a[i], a[pos[i]]);
}


CompilationN/AN/ACompile OKScore: N/A

Testcase #15 s762 MB + 1004 KBTime Limit ExceededScore: 0


Judge Duck Online | 评测鸭在线
Server Time: 2025-09-16 20:51:29 | Loaded in 0 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠