提交记录 10259


用户 题目 状态 得分 用时 内存 语言 代码长度
user1 router32. 测测你的路由器 Wrong Answer 50 4.504 s 46768 KB C++11 453 B
提交时间 评测时间
2019-09-16 23:27:08 2020-08-01 02:05:02
#include <unordered_map>
#include "router.h"

std::unordered_map<long long, unsigned> M;

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

CompilationN/AN/ACompile OKScore: N/A

Testcase #114.45 us24 KBAcceptedScore: 25

Testcase #2194.979 ms42 MB + 808 KBAcceptedScore: 25

Testcase #32.29 s44 MB + 624 KBWrong AnswerScore: 0

Testcase #44.504 s45 MB + 688 KBWrong AnswerScore: 0


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