結果

問題 No.182 新規性の虜
ユーザー nonamaenonamae
提出日時 2022-07-29 17:11:43
言語 C
(gcc 12.3.0)
結果
RE  
実行時間 -
コード長 1,357 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 30,052 KB
実行使用メモリ 4,568 KB
最終ジャッジ日時 2023-09-26 13:56:12
合計ジャッジ時間 5,467 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
evil01.txt RE -
evil02.txt RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘radix_sort64’ 内:
main.c:15:9: 警告: 関数 ‘memset’ の暗黙的な宣言です [-Wimplicit-function-declaration]
   15 |         memset(work2, 0, 0x10000 * sizeof(uint64_t));
      |         ^~~~~~
main.c:4:1: 備考: include ‘<string.h>’ or provide a declaration of ‘memset’
    3 | #include <stdint.h>
  +++ |+#include <string.h>
    4 | 
main.c:15:9: 警告: 組み込み関数 ‘memset’ の互換性がない暗黙的な宣言です [-Wbuiltin-declaration-mismatch]
   15 |         memset(work2, 0, 0x10000 * sizeof(uint64_t));
      |         ^~~~~~
main.c:15:9: 備考: include ‘<string.h>’ or provide a declaration of ‘memset’

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

void radix_sort64(uint64_t *a, int a_len) {
    uint64_t *work0 = (uint64_t *)calloc(0x10000, sizeof(uint64_t));
    uint64_t *work1 = (uint64_t *)calloc(a_len, sizeof(uint64_t));
    uint64_t *work2 = (uint64_t *)calloc(0x10000, sizeof(uint64_t));
    #ifdef LOCAL
    if (work0 == NULL || work1 == NULL || work2 == NULL) exit(EXIT_FAILURE);
    #endif
    uint64_t shift = 0;
    __uint128_t x = 0;
    while (shift < 64ul) {
        memset(work2, 0, 0x10000 * sizeof(uint64_t));
        for (int i = 0; i < a_len; i++) {
            x = (a[i] >> shift) & 0xffff;
            work2[x]++;
            work1[i] = a[i];
        }
        work0[0] = 0;
        for (uint64_t u = 0; u < 0xffff; u++) work0[u + 1] = work0[u] + work2[u];
        for (int i = 0; i < a_len; i++) {
            x = (work1[i] >> shift) & 0xffff;
            a[work0[x]] = work1[i];
            work0[x]++;
        }
        shift += 16;
    }
    free(work0);
    free(work1);
    free(work2);
}

int main(void) {
    int n; scanf("%d", &n);
    int64_t a[n + 2];
    for (int i = 0; i < n; ++i) scanf("%lld", a[i]);
    a[n] = 0;
    a[n + 1] = 1e9 + 7;
    radix_sort64(a, n + 2);
    int ans = 0;
    for (int i = 1; i <= n; ++i) if (a[i - 1] != a[i] && a[i] != a[i + 1]) ++ans;
    printf("%d\n", ans);
    return 0;
}
0