提交记录 13286


用户 题目 状态 得分 用时 内存 语言 代码长度
return20071007 router32. 测测你的路由器 Wrong Answer 25 1.697 s 9736 KB C++11 710 B
提交时间 评测时间
2020-08-01 09:50:40 2020-08-01 09:50:45
#include<bits/stdc++.h>
#include"router.h"
using namespace std;
const unsigned N=827300;
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;
unsigned next[N];
void init(int n,int q,const RoutingTableEntry*a){
	for(int i=0;i<n;++i){
		for(int j=1;j<=32-a[i].len;++j)hop[make_pair(a[i].addr&(1u<<j),32-j)]=a[i].nexthop;
	}
}
unsigned query(unsigned addr){
	unsigned len=31;
	while(addr){
		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.43 us40 KBAcceptedScore: 25

Testcase #2128.475 ms9 MB + 520 KBWrong AnswerScore: 0

Testcase #3914.369 ms9 MB + 520 KBWrong AnswerScore: 0

Testcase #41.697 s9 MB + 520 KBWrong AnswerScore: 0


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