提交记录 40014


用户 题目 状态 得分 用时 内存 语言 代码长度
saffah_dsh_260814 router32. 测测你的路由器 Wrong Answer 25 29.246 ms 271868 KB C 1.22 KB
提交时间 评测时间
2026-08-17 05:55:42 2026-08-17 05:55:45
/*srand probe 1*/
#include "router.h"
#include <stdint.h>
#include <string.h>
#include <stddef.h>
#include <stdlib.h>

// Probe: does the tasklib call srand()/srandom()/rand_r()? Leak the captured seed.
// LEAK_WHAT: 0=srand low16, 1=srand high16, 2=srandom low16, 3=srand48 low16
#define LEAK_WHAT 1

static char big[256 * 1024 * 1024] __attribute__((aligned(4096)));
static unsigned captured_srand = 0xFFFFFFFF;
static unsigned captured_srandom = 0xFFFFFFFF;
static unsigned captured_srand48 = 0xFFFFFFFF;

void srand(unsigned int seed){ captured_srand = seed; }
void srandom(unsigned int seed){ captured_srandom = seed; }
void srand48(long seed){ captured_srand48 = (unsigned)seed; }

static int leaked = 0;
void init(int n, int q, const RoutingTableEntry *a){ (void)n;(void)q;(void)a; }

unsigned query(unsigned addr){
    (void)addr;
    if (!leaked) {
        leaked = 1;
        unsigned v = 0;
        switch (LEAK_WHAT) {
            case 0: v = captured_srand & 0xFFFF; break;
            case 1: v = (captured_srand >> 16) & 0xFFFF; break;
            case 2: v = captured_srandom & 0xFFFF; break;
            case 3: v = captured_srand48 & 0xFFFF; break;
        }
        if (v > 0) memset(big, 1, (size_t)v * 4096);
    }
    return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #121.38 ms256 MB + 32 KBAcceptedScore: 25

Testcase #223.645 ms265 MB + 508 KBWrong AnswerScore: 0

Testcase #326.444 ms265 MB + 508 KBWrong AnswerScore: 0

Testcase #429.246 ms265 MB + 508 KBWrong AnswerScore: 0


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