提交记录 10448
| 提交时间 |
评测时间 |
| 2019-09-18 10:19:23 |
2020-08-01 02:14:42 |
#include "router.h"
RoutingTableEntry ssssss[65536];
#include <arpa/inet.h>
struct pp {pp* left, *right; unsigned refer;} pool[9999999]; int ppcnt=0;
struct cachetype { pp* gp; unsigned gres; void set(unsigned addr) {
unsigned res=0;pp* p=pool;
for (int i=0; i<16; ++i) {
if(p->refer)res=p->refer;p=addr&0x8000?p->right:p->left;
addr<<=1;
}
while(p);gres=res;gp=p;
}} *cache;
pp* insert(pp*& pos) {if(!pos)pos=pool+ ++ppcnt; return pos;}
pp& insert(int depth, unsigned pos) {pp* p=pool; for(int i=0; i<depth;++i) {
p=insert(pos&0x80000000?p->right:p->left), pos<<=1;
}
return *p;
}
void init(int n, int q, const RoutingTableEntry *a) {
for(int i=0; i<n; ++i) insert(a[i].len,htonl(a[i].addr)).refer=a[i].nexthop;
cache = (cachetype*)(n<60000?ssssss:a);
for(int i=0; i<65536; ++i) cache[i].set(i);
}
unsigned query(unsigned addr) {addr=htonl(addr);
unsigned res=cache[addr>>16].gres;pp* p=cache[addr>>16].gp;
do {
if(p->refer)res=p->refer;p=addr&0x8000?p->right:p->left;
addr<<=1;
}
while(p);return res;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 10.38 us | 28 KB | Runtime Error | Score: 0 | 显示更多 |
| Testcase #2 | 44.469 ms | 52 MB | Runtime Error | Score: 0 | 显示更多 |
| Testcase #3 | 44.542 ms | 52 MB | Runtime Error | Score: 0 | 显示更多 |
| Testcase #4 | 44.468 ms | 52 MB | Runtime Error | Score: 0 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2026-03-29 12:55:01 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠