提交记录 10327


用户 题目 状态 得分 用时 内存 语言 代码长度
jiegec router32. 测测你的路由器 Accepted 100 6.648 s 48488 KB C++ 478 B
提交时间 评测时间
2019-09-17 17:07:09 2020-08-01 02:08:01
#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));
	}
	
	return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #112.93 us24 KBAcceptedScore: 25

Testcase #2100.127 ms47 MB + 360 KBAcceptedScore: 25

Testcase #33.375 s47 MB + 360 KBAcceptedScore: 25

Testcase #46.648 s47 MB + 360 KBAcceptedScore: 25


Judge Duck Online | 评测鸭在线
Server Time: 2024-05-08 05:04:56 | Loaded in 0 ms | Server Status
个人娱乐项目,仅供学习交流使用