提交记录 20736


用户 题目 状态 得分 用时 内存 语言 代码长度
jyx router32. 测测你的路由器 Accepted 100 6.649 s 48488 KB C++ 478 B
提交时间 评测时间
2023-12-09 20:11:02 2023-12-09 20:11:19
#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 #115.23 us24 KBAcceptedScore: 25

Testcase #2100.064 ms47 MB + 360 KBAcceptedScore: 25

Testcase #33.376 s47 MB + 360 KBAcceptedScore: 25

Testcase #46.649 s47 MB + 360 KBAcceptedScore: 25


Judge Duck Online | 评测鸭在线
Server Time: 2024-05-07 16:32:02 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用