提交记录 10771


用户 题目 状态 得分 用时 内存 语言 代码长度
duck router32. 测测你的路由器 Accepted 100 10.935 s 48488 KB C++ 623 B
提交时间 评测时间
2019-09-30 00:31:33 2020-08-01 02:28:56
#include <map>
#include <arpa/inet.h>
#include "router.h"

std::map<unsigned, unsigned> M[33];

void ins(const RoutingTableEntry *e) {
    M[e->len][e->addr] = e->nexthop;
}

void init(int n, int q, const RoutingTableEntry *tbl) {
    for (int i = 0; i < n; i++) {
        ins(tbl + i);
    }
}

unsigned query(unsigned addr) {
    unsigned addr0=addr;
    addr = htonl(addr);

    for (int i = 32; i >= 0; i--) {
        if (M[i].count(addr0) > 0) {
            return M[i][addr0];
        }
        addr &= ~(1u << (32 - i));
        addr0&=~(1u<<((i-1)/8*8+7-(i-1)%8));
        addr=htonl(addr0);
    }

    return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #113.68 us24 KBAcceptedScore: 25

Testcase #2322.961 ms47 MB + 360 KBAcceptedScore: 25

Testcase #35.63 s47 MB + 360 KBAcceptedScore: 25

Testcase #410.935 s47 MB + 360 KBAcceptedScore: 25


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