提交记录 59433


用户 题目 状态 得分 用时 内存 语言 代码长度
saffah_dsh_v41_0919 1001a. 测测你的排序2 Wrong Answer 0 2.689 ms 44004 KB C++17 1.43 KB
提交时间 评测时间
2026-09-19 20:31:57 2026-09-19 20:37:10
#define STAT 0
/* 1001a input-statistics probe via the memory side channel.
   STAT 0: n | 1: non-empty top-9-bit buckets | 2: max bucket count | 3: already sorted? */
typedef unsigned u32;
static char pad[16 << 20];
static inline void dumpv(unsigned long long v) {
    volatile char *p = pad;
    for (unsigned long long i = 0; i < v; i++) p[i * 4096] = 1;
}
#ifndef STAT
#define STAT 0
#endif
void sort(unsigned *a, int n) {
    unsigned long long v = 0;
#if STAT == 0
    v = (unsigned long long)n;
#elif STAT == 1
    { static unsigned cnt[512]; for (int k = 0; k < 512; k++) cnt[k] = 0;
      for (int i = 0; i < n; i++) cnt[a[i] >> 23]++;
      int ne = 0; for (int k = 0; k < 512; k++) if (cnt[k]) ne++; v = (unsigned long long)ne; }
#elif STAT == 2
    { static unsigned cnt[512]; for (int k = 0; k < 512; k++) cnt[k] = 0;
      for (int i = 0; i < n; i++) cnt[a[i] >> 23]++;
      unsigned mx = 0; for (int k = 0; k < 512; k++) if (cnt[k] > mx) mx = cnt[k]; v = mx; }
#elif STAT == 3
    { int s = 1; for (int i = 1; i < n; i++) if (a[i] < a[i - 1]) { s = 0; break; } v = (unsigned long long)s; }
#elif STAT == 4
    { static unsigned cnt[512]; for (int k = 0; k < 512; k++) cnt[k] = 0;
      for (int i = 0; i < n; i++) cnt[(a[i] >> 23) & 511]++;
      unsigned long long s2 = 0; for (int k = 0; k < 512; k++) s2 += (unsigned long long)cnt[k] * cnt[k];
      v = s2 / 1000; }
#endif
    (void)a; (void)n;
    dumpv(1000 + v);
}

//xxxxxxxxxxxxxxxxxx

CompilationN/AN/ACompile OKScore: N/A

Testcase #12.689 ms42 MB + 996 KBWrong AnswerScore: 0


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