提交记录 13334
| 提交时间 |
评测时间 |
| 2020-08-01 10:55:50 |
2020-08-01 10:55:52 |
#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, res = 0;
for (int i = 31; i >= 0; --i) {
unsigned c = (addr >> i) & 1;
if (ch[u][c] == 0) return res;
u = ch[u][c];
if (val[u] != 0) res = val[u];
}
return res;
}
}
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 | 11.91 us | 32 KB | Accepted | Score: 25 | 显示更多 |
| Testcase #2 | 30.993 ms | 12 MB + 268 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #3 | 84.715 ms | 12 MB + 268 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #4 | 138.656 ms | 12 MB + 268 KB | Wrong Answer | Score: 0 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2026-03-24 13:32:02 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠