提交记录 13333
| 提交时间 |
评测时间 |
| 2020-08-01 10:53:46 |
2020-08-01 10:53:48 |
#include "router.h"
namespace trie {
const unsigned MaxN = 2827088;
unsigned cnt;
unsigned ch[MaxN * 32 + 5][2];
unsigned val[MaxN * 32 + 5];
inline void insert(unsigned addr, unsigned char 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.04 us | 32 KB | Accepted | Score: 25 | 显示更多 |
| Testcase #2 | 30.998 ms | 12 MB + 268 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #3 | 71.523 ms | 12 MB + 268 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #4 | 112.039 ms | 12 MB + 268 KB | Wrong Answer | Score: 0 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2026-03-24 13:30:29 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠