提交记录 10710
提交时间 |
评测时间 |
2019-09-27 14:46:45 |
2020-08-01 02:20:02 |
#include "router.h"
#include <arpa/inet.h>
#include <unordered_map>
std::unordered_map<unsigned,unsigned> Map[33];
void init(int n,int q,const RoutingTableEntry *a){
const RoutingTableEntry *tmp=nullptr;
for(int i=0;i<n;i++){
tmp = a + i;
Map[tmp->len][htonl(tmp->addr)] = tmp->nexthop;
}
}
unsigned query(unsigned addr){
addr = htonl(addr);
for(int len = 32;len>=0;len--){
if(Map[len].count(addr))
return Map[len][addr];
addr &=~(1u << (32-len));
}
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 15.31 us | 24 KB | Accepted | Score: 25 | 显示更多 |
Testcase #2 | 150.987 ms | 42 MB + 308 KB | Accepted | Score: 25 | 显示更多 |
Testcase #3 | 1.29 s | 42 MB + 308 KB | Accepted | Score: 25 | 显示更多 |
Testcase #4 | 2.429 s | 42 MB + 308 KB | Accepted | Score: 25 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:44:39 | Loaded in 0 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠