提交记录 27778


用户 题目 状态 得分 用时 内存 语言 代码长度
Izumi_Sagiri wc2017b1. 【WC2017】挑战-任务1 Time Limit Exceeded 34 3 s 1562524 KB C++17 1.20 KB
提交时间 评测时间
2025-01-20 01:21:00 2025-01-20 01:21:10
#include <bits/stdc++.h>

// Function to get the digit at the dth position
unsigned getDigit(unsigned number, int d, int radix) {
    return (number / static_cast<unsigned>(pow(radix, d))) % radix;
}

// Counting sort for a specific digit
void countingSortByDigit(unsigned* a, int n, int digit, int radix) {
    std::vector<int> count(radix, 0);
    std::vector<unsigned> output(n);

    // Count occurrences of each digit
    for (int i = 0; i < n; i++) {
        count[getDigit(a[i], digit, radix)]++;
    }

    // Cumulative count
    for (int i = 1; i < radix; i++) {
        count[i] += count[i - 1];
    }

    // Build the output array
    for (int i = n - 1; i >= 0; i--) {
        output[count[getDigit(a[i], digit, radix)] - 1] = a[i];
        count[getDigit(a[i], digit, radix)]--;
    }

    // Copy the output array to the original array
    for (int i = 0; i < n; i++) {
        a[i] = output[i];
    }
}

// Radix sort function
void sort(unsigned* a, int n) {
    const int radix = 256; // Using 8 bits per digit
    const int numDigits = 4; // 32 bits / 8 bits per digit

    // Sort for each digit
    for (int digit = 0; digit < numDigits; digit++) {
        countingSortByDigit(a, n, digit, radix);
    }
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #180.829 ms812 KBAcceptedScore: 34

Testcase #23 s762 MB + 988 KBTime Limit ExceededScore: 0

Testcase #33 s1525 MB + 924 KBTime Limit ExceededScore: 0


Judge Duck Online | 评测鸭在线
Server Time: 2025-02-05 21:02:05 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠