提交记录 10527


用户 题目 状态 得分 用时 内存 语言 代码长度
user1 router32. 测测你的路由器 Runtime Error 25 47.17 ms 43336 KB C++11 739 B
提交时间 评测时间
2019-09-18 19:57:42 2020-08-01 02:16:35
#include <unordered_map>
#include <arpa/inet.h>
#include "router.h"

std::unordered_map<unsigned, unsigned> M(888888), G(88888);

void ins(const RoutingTableEntry *e) {
if(e->len==32)
	G[htonl(e->addr)] = e->nexthop; else M[htonl(e->addr)>>32-e->len | 1<<e->len]= e->nexthop; 
}

void init(int n, int q, const RoutingTableEntry *tbl) {
	for (int i = 0; i < n; i++) {
		ins(tbl + i);
	}
}
int Rho; int Esho[999999];
unsigned QQ(unsigned x) {

	if(Rho++==0) for(int i=x*1024; i-=1024; )Esho[i]=9; return x;
}
unsigned query(unsigned addr) {
	addr = htonl(addr); if(G.count(addr)) return G[addr];
	addr = addr>>1 | 0x80000000;
	for (int i = 31; i >= 0; i--) { 
		if (M.count(addr) > 0) {
			return QQ(M[addr]);
		}
		addr>>=1;
	}
	return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #11.128 ms7 MB + 632 KBAcceptedScore: 25

Testcase #247.128 ms42 MB + 328 KBRuntime ErrorScore: 0

Testcase #347.17 ms42 MB + 328 KBRuntime ErrorScore: 0

Testcase #447.143 ms42 MB + 328 KBRuntime ErrorScore: 0


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