提交记录 13344
| 提交时间 |
评测时间 |
| 2020-08-01 11:15:00 |
2020-08-01 11:15:04 |
#include "router.h"
struct Trienode{
unsigned nexthop;
unsigned ls,rs;
bool end;
}T[30100000];
int t;
void init(int n, int q, const RoutingTableEntry *a) {
for(const RoutingTableEntry *i=a,*e=a+n;i!=e;++i){
unsigned cur=0,val=i->addr;
for(register int b=31,b_end=31-i->len;b!=b_end;--b){
if(val>>b&1){
if(!T[cur].ls)T[cur].ls=++t;
cur=T[cur].ls;
}
else{
if(!T[cur].rs)T[cur].rs=++t;
cur=T[cur].rs;
}
}
T[cur].end=true;
T[cur].nexthop=i->nexthop;
}
}
unsigned query(unsigned addr) {
unsigned cur=0,ans=0;
if(T[cur].end)ans=T[cur].nexthop;
for(register int i=31;~i;--i){
if(addr>>i&1)cur=T[cur].rs;
else cur=T[cur].ls;
if(!cur)return ans;
else if(T[cur].end)ans=T[cur].nexthop;
}
return ans;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 12.27 us | 28 KB | Accepted | Score: 25 | 显示更多 |
| Testcase #2 | 47.16 ms | 13 MB + 184 KB | Accepted | Score: 25 | 显示更多 |
| Testcase #3 | 107.832 ms | 13 MB + 184 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #4 | 168.263 ms | 13 MB + 184 KB | Wrong Answer | Score: 0 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2026-03-24 12:53:07 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠