提交记录 10435


用户 题目 状态 得分 用时 内存 语言 代码长度
user1 router32. 测测你的路由器 Wrong Answer 25 254.612 ms 43052 KB C++11 650 B
提交时间 评测时间
2019-09-18 09:26:54 2020-08-01 02:14:35
#include "router.h"
#include <arpa/inet.h>

struct pp {pp* left, *right; unsigned refer;} pool[9999999]; int ppcnt=0;
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<pos; ++i) {
p=insert(pos&0x80000000?p->right:p->left), pos<<=1;
}while(pos);
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;
}

unsigned query(unsigned addr) {addr=htonl(addr);
	unsigned res=0;pp* p=pool;
	do {
		if(p->refer)res=p->refer;p=addr&0x80000000?p->right:p->left;
addr<<=1;
}
	while(p);return res;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #113.54 us32 KBAcceptedScore: 25

Testcase #239.14 ms42 MB + 44 KBWrong AnswerScore: 0

Testcase #3147.47 ms42 MB + 44 KBWrong AnswerScore: 0

Testcase #4254.612 ms42 MB + 44 KBWrong AnswerScore: 0


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