提交记录 10272
| 提交时间 |
评测时间 |
| 2019-09-17 01:09:01 |
2020-08-01 02:06:33 |
#include <algorithm>
#include "router.h"
#define __builtin_bswap32
const RoutingTableEntry* tblGlobal;
int nGlobal;
bool operator<(const RoutingTableEntry& a, const RoutingTableEntry& b) {
return __builtin_bswap32(a.addr)<__builtin_bswap32(b.addr) ||
__builtin_bswap32(a.addr)==__builtin_bswap32(b.addr) && a.len<b.len;
}
void init(int n, int q, const RoutingTableEntry *tbl) {
tblGlobal = tbl; nGlobal=n;std::sort((RoutingTableEntry *)tbl, (RoutingTableEntry *)tbl+n);
}
unsigned query(unsigned addr) {
RoutingTableEntry tester; tester.addr=addr;
for (tester.len = 32; tester.len !=255; tester.len--) {
auto tbl=std::lower_bound(tblGlobal, tblGlobal+nGlobal, tester);
if (tbl!=tblGlobal+nGlobal && !(tester<*tbl)) return (*tbl).nexthop;
tester.addr &= ~(1u << (32 - tester.len^24));
}
return 0;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 11.97 us | 24 KB | Accepted | Score: 25 | 显示更多 |
| Testcase #2 | 56.334 ms | 9 MB + 500 KB | Accepted | Score: 25 | 显示更多 |
| Testcase #3 | 2.158 s | 9 MB + 500 KB | Accepted | Score: 25 | 显示更多 |
| Testcase #4 | 4.26 s | 9 MB + 500 KB | Accepted | Score: 25 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2026-03-29 20:13:25 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠