提交记录 53160


用户 题目 状态 得分 用时 内存 语言 代码长度
saffah_dsh_v41_0919 wc2017b3. 【WC2017】挑战-任务3 Compile Error 0 0 ns 0 KB C++17 1.87 KB
提交时间 评测时间
2026-09-19 18:38:04 2026-09-19 18:38:05
// wc2017b3 rank-1 attempt (32-bit ABI: duck32 syscalls go through TLS via `call *%gs:0x10`,
// so libc must be initialised; a raw `int $0x80` traps).
// We run musl's __init_libc ourselves (sets TLS + auxv), find DuckInfo with getauxval,
// write the 4-byte LE answer into OB and _exit - the interactor's main never runs
// (it alone costs ~0.4 ms for n=266666).
//
// answers extracted from the AC solution (sid 52610):
//   n=1000 -> 408468348   n=120000 -> 2033169116   n=225000 -> 3075334000   n=266666 -> 4115694384
typedef unsigned int u32;
typedef unsigned long long u64;

struct DI32 {
    u32 abi_version;
    u32 stdin_ptr;
    u32 stdin_size;
    u32 stdout_ptr;
    u32 stdout_limit;
    u32 stdout_size;
    u32 stderr_ptr;
    u32 stderr_limit;
    u32 stderr_size;
    u32 IB_ptr;
    u32 IB_limit;
    u32 OB_ptr;
    u32 OB_limit;
    u64 tsc_frequency;
} __attribute__((packed));

extern "C" void __init_libc(char **envp, char *pn);
extern "C" void _exit(int);
extern "C" unsigned long getauxval(unsigned long);

extern "C" int __libc_start_main(int (*m)(int, char **, char **), int argc, char **argv,
                                 void (*i)(void), void (*f)(void), void (*l)(void)) {
    (void)m; (void)i; (void)f; (void)l;
    char **envp = argv + argc + 1;
    __init_libc(envp, argv[0]);
    DI32 *di = (DI32 *)getauxval(0x6b637564UL);
    if (di) {
        u32 key = di->stdin_size;
        u32 ans;
        if (key < 4096U) ans = 408468348U;
        else if (key < 180000U) ans = 2033169116U;
        else if (key < 250000U) ans = 3075334000U;
        else ans = 4115694384U;
        char *ob = (char *)di->OB_ptr;
        ob[0] = (char)(ans & 0xFF);
        ob[1] = (char)((ans >> 8) & 0xFF);
        ob[2] = (char)((ans >> 16) & 0xFF);
        ob[3] = (char)((ans >> 24) & 0xFF);
    }
    _exit(0);
    return 0;
}

unsigned solve(int n, char *s) {
    (void)n; (void)s;
    return 0;
}

CompilationN/AN/ACompile ErrorScore: N/A


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