提交记录 10712
| 提交时间 |
评测时间 |
| 2019-09-27 14:56:16 |
2020-08-01 02:20:03 |
# define max_entries 827088ul
# include "router.h"
int n_nodes;
unsigned trie_childs[max_entries * 32][2];
unsigned trie_nexthop[max_entries * 32];
void init(int n, int q, const RoutingTableEntry *a) {
int n_entries = n;
RoutingTableEntry *routing_table = (RoutingTableEntry*) a;
for (unsigned i = 0; i < n_entries; ++ i) {
unsigned addr = routing_table[i].addr, bit;
unsigned mask_length = routing_table[i].len, current = 0;
for (unsigned j = 0; j < mask_length; ++ j) {
bit = (addr >> (31ul - j)) & 1ul;
if (!trie_childs[current][bit]) {
trie_childs[current][bit] = ++ n_nodes;
trie_nexthop[n_nodes] = trie_nexthop[current];
}
current = trie_childs[current][bit];
}
trie_nexthop[current] = routing_table[i].nexthop;
}
}
unsigned query(unsigned addr) {
unsigned current = 0, nexthop = trie_nexthop[0];
for (unsigned i = 0; i < 32; ++ i) {
unsigned bit = (addr >> (31ul - i)) & 1ul;
if (trie_childs[current][bit])
current = trie_childs[current][bit];
else break;
nexthop = trie_nexthop[current];
}
return nexthop;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 12.51 us | 32 KB | Accepted | Score: 25 | 显示更多 |
| Testcase #2 | 31.213 ms | 12 MB + 268 KB | Accepted | Score: 25 | 显示更多 |
| Testcase #3 | 80.455 ms | 12 MB + 268 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #4 | 129.635 ms | 12 MB + 268 KB | Wrong Answer | Score: 0 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2026-03-29 01:43:45 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠