提交记录 10263


用户 题目 状态 得分 用时 内存 语言 代码长度
user1 router32. 测测你的路由器 Compile Error 0 0 ns 0 KB C++11 658 B
提交时间 评测时间
2019-09-16 23:47:24 2020-08-01 02:04:35
#include <algorithm>
#include "router.h"

RoutingTableEntry* tblGlobal;
int nGlobal;

void init(int n, int q, const RoutingTableEntry *tbl) {
	tblGlobal = tbl; nGlobal=n;
}

bool operator<(const tblGlobal& a, const tblGlobal& b) {
    return __builtin_bswap32(a.addr)<__builtin_bswap32(b.addr) || 
    __builtin_bswap32(a.addr)==__builtin_bswap32(b.addr) && a.len<b.len;
}

unsigned query(unsigned addr) {
         RoutingTableEntry tester; tester.addr=addr;
	for (tester.len = 32; tester.len >= 0; tester.len--) {
		auto tbl=std::lower_bound(tblGlobal, tblGlobal+nGlobal, tester);
                if (!(tester<*tbl)) return (*tbl).nexthop;
	}
	
	return 0;
}

CompilationN/AN/ACompile ErrorScore: N/A


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