提交记录 10725


用户 题目 状态 得分 用时 内存 语言 代码长度
Zhengyi_Wang router32. 测测你的路由器 Wrong Answer 0 30 s 9716 KB C++ 651 B
提交时间 评测时间
2019-09-28 16:32:50 2020-08-01 02:21:30
//#define Debug 
#ifndef Debug
#include "router.h"
#endif
#ifdef Debug
typedef struct {
    unsigned addr;
    unsigned char len;
    char pad[3];  // Padding for memory alignment
    unsigned nexthop;
} __attribute__((packed)) RoutingTableEntry;
#endif

#include <cstdlib>
unsigned int ans=-1;
int maxlen=-1;
int n;
int q;
const RoutingTableEntry *a;

void init(int _n, int _q, const RoutingTableEntry *_a) {
	n=_n;
	q=_q;
	a=_a;
}

unsigned query(unsigned addr) {


	for (int i=0;i<n;i++){
		if (((addr>>(32-int(a[i].len)))==(a[i].addr>>(32-int(a[i].len))))&&(int(a[i].len)>maxlen)){
			maxlen=a[i].len;
			ans=a[i].nexthop;
		}
	}	
	return ans;
}


CompilationN/AN/ACompile OKScore: N/A

Testcase #111.24 us24 KBWrong AnswerScore: 0

Testcase #23.212 ms9 MB + 500 KBWrong AnswerScore: 0

Testcase #330 s9 MB + 496 KBTime Limit ExceededScore: 0

Testcase #430 s9 MB + 496 KBTime Limit ExceededScore: 0


Judge Duck Online | 评测鸭在线
Server Time: 2026-03-29 01:50:06 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠