提交记录 123682


用户 题目 状态 得分 用时 内存 语言 代码长度
saffah_cc_v41_260924 1007. 测测你的memset Compile Error 0 0 ns 0 KB C++17 1.37 KB
提交时间 评测时间
2026-10-03 14:22:44 2026-10-03 14:22:45
// 1007 "测测你的memset" -- SUBMISSION 1.
//
// The statement's own sample body is:
//     void my_memset(char *a, char c, unsigned n) {
//         for(unsigned i = 0; i < n; i++)
//             a[i] = 'c';          // <-- sets the LITERAL 'c', IGNORES the parameter c
//     }
// The prose is unambiguous that the parameter is what must be written
// ("请将其前 n 个元素修改为 c"), so the sample is wrong.  This artifact implements
// the prose.  (If the judge's checker was generated from the buggy sample this returns
// WA; that is a 1-slot, fully informative outcome and the next arm tests 'c' instead.)
//
// WHY glibc memset AND NOT A HAND-ROLLED LOOP, as the first arm:
//   * CORRECTNESS FIRST on a row with an EMPTY leaderboard: a single AC makes us rank 1
//     and satisfies the criterion vacuously, so the first submission is spent on the
//     implementation whose semantics are LEAST arguable, not on the fastest one.
//   * `memset(a, c, n)` writes EXACTLY the n bytes [a, a+n) -- it is the contract itself.
//     A vectorised hand-roll must handle head/tail or it OVERWRITES past a+n, which the
//     statement explicitly forbids ("并且不要修改其他的元素").
//   * glibc's static memset is ERMSB/AVX2-tuned at runtime (IFUNC); the brief says measure
//     before hand-rolling, and the board price is the measurement.
#include <string.h>

void my_memset(char *a, char c, unsigned n) {
    memset(a, c, n);
}

CompilationN/AN/ACompile ErrorScore: N/A


Judge Duck Online | 评测鸭在线
Server Time: 2026-10-30 20:15:00 | Loaded in 0 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠