提交记录 14181


用户 题目 状态 得分 用时 内存 语言 代码长度
andrewfeng router32. 测测你的路由器 Wrong Answer 25 12.712 ms 31704 KB C++ 873 B
提交时间 评测时间
2020-09-17 17:52:00 2020-09-17 17:52:07
#include "router.h"
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <vector>

std::vector<RoutingTableEntry> table;

int q_num;

void init(int n, int q, const RoutingTableEntry *a) {
	for (int i = 0; i < n; ++i) {
        table.push_back(a[i]);
    }
    q_num = q;
}

int getSubnetMask(uint32_t a, uint32_t b) {
  int cnt = 0;
  for (int i = 0; i < 32; ++i) {
    if ( (a & 1) == (b & 1)) {
      a >>= 1;
      b >>= 1;
      cnt ++;
    } else break;
  }
  return cnt;
}

bool checkIpMatch(uint32_t a, uint32_t b, uint32_t len) {
  uint32_t subnetmask = 1;
  while (len > 1) {
    subnetmask = (subnetmask << 1) + 1;
    len--;
  }
  if ((a & subnetmask) == (b & subnetmask)) return true;
  // printf("a = %u, b = %u, [a] = %u, [b] = %u\n", a, b, (a & subnetmask), (b & subnetmask));
  return false;
}

unsigned query(unsigned addr) {
    return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #112.96 us24 KBAcceptedScore: 25

Testcase #27.041 ms30 MB + 984 KBWrong AnswerScore: 0

Testcase #39.875 ms30 MB + 984 KBWrong AnswerScore: 0

Testcase #412.712 ms30 MB + 984 KBWrong AnswerScore: 0


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