提交记录 13332
| 提交时间 |
评测时间 |
| 2020-08-01 10:49:35 |
2020-08-01 10:49:37 |
#include "router.h"
namespace trie {
const unsigned MaxN = 827088;
unsigned cnt;
unsigned ch[MaxN * 32 + 5][2];
unsigned val[MaxN * 32 + 5];
inline void insert(unsigned addr, unsigned len, unsigned nexthop) {
unsigned u = 0;
for (int i = 31; i >= 32 - len; --i) {
unsigned c = (addr >> i) & 1;
if (ch[u][c] == 0) ch[u][c] = ++cnt;
u = ch[u][c];
}
val[u] = nexthop;
}
inline unsigned query(unsigned addr) {
int u = 0;
for (int i = 31; i >= 0; --i) {
unsigned c = (addr >> i) & 1;
if (ch[u][c] == 0) return 0;
u = ch[u][c];
}
return val[u];
}
}
void init(int n, int q, const RoutingTableEntry *a) {
for (int i = 0; i < n; ++i)
trie::insert(a[i].addr, a[i].len, a[i].nexthop);
}
unsigned query(unsigned addr) {
return trie::query(addr);
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 12.45 us | 32 KB | Accepted | Score: 25 | 显示更多 |
| Testcase #2 | 52.861 ms | 211 MB + 488 KB | Runtime Error | Score: 0 | 显示更多 |
| Testcase #3 | 52.852 ms | 211 MB + 488 KB | Runtime Error | Score: 0 | 显示更多 |
| Testcase #4 | 52.855 ms | 211 MB + 488 KB | Runtime Error | Score: 0 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2026-03-24 13:30:20 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠