提交记录 20736 
	
	
	
		
			
			
				
					|  提交时间  | 
					 评测时间  | 
				
				
					|  2023-12-09 20:11:02  | 
 2023-12-09 20:11:19  | 
				
			
			
			
			
			
				
				#include <map>
#include <arpa/inet.h>
#include "router.h"
std::map<unsigned, unsigned> M[33];
void ins(const RoutingTableEntry *e) {
	M[e->len][htonl(e->addr)] = e->nexthop;
}
void init(int n, int q, const RoutingTableEntry *tbl) {
	for (int i = 0; i < n; i++) {
		ins(tbl + i);
	}
}
unsigned query(unsigned addr) {
	addr = htonl(addr);
	
	for (int i = 32; i >= 0; i--) {
		if (M[i].count(addr) > 0) {
			return M[i][addr];
		}
		addr &= ~(1u << (32 - i));
	}
	
	return 0;
}
				
				
				| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 | 
| Testcase #1 | 15.23 us | 24 KB | Accepted | Score: 25 | 显示更多 | 
| Testcase #2 | 100.064 ms | 47 MB + 360 KB | Accepted | Score: 25 | 显示更多 | 
| Testcase #3 | 3.376 s | 47 MB + 360 KB | Accepted | Score: 25 | 显示更多 | 
| Testcase #4 | 6.649 s | 47 MB + 360 KB | Accepted | Score: 25 | 显示更多 | 
 
			 
		 
	 
	
	
	
		
			Judge Duck Online | 评测鸭在线 
			Server Time: 2025-11-04 16:04:47 | Loaded in 1 ms |  Server Status  
			个人娱乐项目,仅供学习交流使用 |  捐赠