提交记录 10698
| 提交时间 |
评测时间 |
| 2019-09-27 10:50:33 |
2020-08-01 02:19:51 |
# define max_entries 827088ul
#include "router.h"
int n_entries, n_nodes;
unsigned trie_childs[max_entries * 32][2];
unsigned trie_nexthop[max_entries * 32];
unsigned one_bit_prefix[33], addr_mask[33];
RoutingTableEntry *routing_table;
void init(int n, int q, const RoutingTableEntry *a) {
n_entries = n;
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;
current = trie_childs[current][bit];
}
trie_nexthop[current] = routing_table[i].nexthop;
}
}
unsigned query(unsigned addr) {
unsigned current = 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
return trie_nexthop[current];
}
return trie_nexthop[current];
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 11.92 us | 32 KB | Accepted | Score: 25 | 显示更多 |
| Testcase #2 | 30.907 ms | 12 MB + 268 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #3 | 75.645 ms | 12 MB + 268 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #4 | 120.373 ms | 12 MB + 268 KB | Wrong Answer | Score: 0 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2026-03-29 02:42:27 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠