提交记录 10323


用户 题目 状态 得分 用时 内存 语言 代码长度
user1 router32. 测测你的路由器 Accepted 100 1.248 s 52812 KB C++11 545 B
提交时间 评测时间
2019-09-17 16:27:15 2020-08-01 02:07:49
#include <unordered_map>
#include <arpa/inet.h>
#include "router.h"

std::unordered_map<unsigned, unsigned> M[4096][33];

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

CompilationN/AN/ACompile OKScore: N/A

Testcase #11.396 ms7 MB + 248 KBAcceptedScore: 25

Testcase #271.953 ms51 MB + 588 KBAcceptedScore: 25

Testcase #3660.141 ms51 MB + 588 KBAcceptedScore: 25

Testcase #41.248 s51 MB + 588 KBAcceptedScore: 25


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