提交记录 13291


用户 题目 状态 得分 用时 内存 语言 代码长度
return20071007 router32. 测测你的路由器 Wrong Answer 25 1.651 s 9732 KB C++11 667 B
提交时间 评测时间
2020-08-01 09:53:17 2020-08-01 09:53:23
#include<bits/stdc++.h>
#include"router.h"
using namespace std;
struct hasher{
	size_t operator()(const pair<unsigned,unsigned>&p)const{
		size_t tmp=hash<unsigned>()(p.first)+0x9e3779b9;
		return tmp^(hash<unsigned>()(p.second)+0x9e3779b9+(tmp<<6)+(tmp>>2));
	}
};
unordered_map<pair<unsigned,unsigned>,unsigned,hasher>hop;
void init(int n,int q,const RoutingTableEntry*a){
	for(int i=0;i<n;++i){
		for(int j=32-a[i].len;j<32;++j)hop[make_pair(a[i].addr&(1u<<j),32-j)]=a[i].nexthop;
	}
}
unsigned query(unsigned addr){
	unsigned len=31;
	while(len){
		if(hop.find(make_pair(addr,len))!=hop.end())return hop[make_pair(addr,len)]; 
		addr>>=1;
		--len;
	}
	return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #140.85 us40 KBAcceptedScore: 25

Testcase #2292.081 ms9 MB + 516 KBWrong AnswerScore: 0

Testcase #3967.558 ms9 MB + 516 KBWrong AnswerScore: 0

Testcase #41.651 s9 MB + 516 KBWrong AnswerScore: 0


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