提交记录 10496


用户 题目 状态 得分 用时 内存 语言 代码长度
user1 router32. 测测你的路由器 Memory Limit Exceeded 0 0 ns 0 KB C++11 1017 B
提交时间 评测时间
2019-09-18 19:03:37 2020-08-01 02:16:08
#pragma GCC optimize("Ofast,no-stack-protector")
#include "router.h"
#include <bits/stdc++.h>
#include <arpa/inet.h>
using namespace std;

unsigned table[1 << 24];

int top = 0;
unsigned shop[0x100000][256];

void ins(unsigned addr, int len, unsigned nexthop)
{
    if(len <= 24)
    {
        addr >>= 8;
        for(int T = 1 << (24 - len); T--; ++addr) table[addr] = nexthop;
    }
    else
    {
        unsigned &son = table[addr >> 8];
        if(son<0xfff00000)
        {
            --top;
            for(int i = 0; i < 256; i++) shop[top+0x100000][i] = son; son=top;
        }
        addr &= 255u;
        for(int T = 1 << (32 - len); T--; ++addr) shop[son+0x100000][addr] = nexthop;
    }
}

void init(int n, int q, const RoutingTableEntry *a)
{
    for(int i = 0; i < n; i++) ins(htonl(a[i].addr), a[i].len, a[i].nexthop);
}

unsigned query(unsigned addr)
{
    addr = htonl(addr);
    unsigned ent = table[addr >> 8];
    if(ent>0xfff00000) return shop[ent+0x100000][addr & 255u];
    else return ent;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #10 ns0 KBMemory Limit ExceededScore: 0

Testcase #20 ns0 KBMemory Limit ExceededScore: 0

Testcase #30 ns0 KBMemory Limit ExceededScore: 0

Testcase #40 ns0 KBMemory Limit ExceededScore: 0


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