提交记录 13316
| 提交时间 |
评测时间 |
| 2020-08-01 10:17:53 |
2020-08-01 10:17:55 |
#include "router.h"
struct TrieNode{
unsigned nexthop;
unsigned is;
unsigned padding1;
unsigned padding2;
TrieNode *c0;
TrieNode *c1;
}T[26466817];
void init(int n, int q, const RoutingTableEntry *a) {
TrieNode *t=T;
for(const RoutingTableEntry *i=a,*e=a+n;i!=e;++i){
TrieNode *v=T;
for(char l=31,r=31-i->len;l!=r;--l){
if((i->addr)>>l&1){
if(v->c1)v=v->c1;
else v=v->c1=++t;
}else{
if(v->c0)v=v->c0;
else v=v->c0=++t;
}
}
v->is=1;
v->nexthop=i->nexthop;
}
//for(TrieNode *v=T;v<=t;++v){
//std::cout<<v<<" c0="<<(v->c0)<<" c1="<<(v->c1)<<" nexthop="<<(v->nexthop)<<std::endl;
//printf("%llx c0=%llx c1=%llx nexthop=%u\n",v,v->c0,v->c1,v->nexthop);
//}
}
unsigned query(unsigned addr) {
unsigned cur=0;
TrieNode *v=T;
for(char l=31;~l;--l){
if(addr>>l&1)v=v->c1;else v=v->c0;
if(v){if(v->is)cur=v->nexthop;}
else return cur;
}
return cur;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 13.01 us | 28 KB | Accepted | Score: 25 | 显示更多 |
| Testcase #2 | 43.057 ms | 16 MB + 884 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #3 | 99.035 ms | 16 MB + 884 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #4 | 154.147 ms | 16 MB + 884 KB | Wrong Answer | Score: 0 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2026-03-24 13:42:12 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠