提交记录 18707


用户 题目 状态 得分 用时 内存 语言 代码长度
nr0728 router32. 测测你的路由器 Time Limit Exceeded 75 30 s 48488 KB C++ 487 B
提交时间 评测时间
2022-12-01 17:18:36 2022-12-01 17:19:12
#include <map>
#include <arpa/inet.h>
#include "router.h"

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

void ins(const RoutingTableEntry *e) {
	M[e->len][htonl(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) {
	addr = htonl(addr);
	
	for (int i = 32; i >= 0; i--) {
		if (M[i].count(addr) > 0) {
			return M[i][addr];
		}
		addr &= ~(1u << (32 - i));
	}
	while(1);
	return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #130 s20 KBTime Limit ExceededScore: 0

Testcase #2100.274 ms47 MB + 360 KBAcceptedScore: 25

Testcase #33.381 s47 MB + 360 KBAcceptedScore: 25

Testcase #46.658 s47 MB + 360 KBAcceptedScore: 25


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