CF GYM 100548 International Collegiate Routing Contest(2014ACM西安现场赛Problem I)

ProblemI. International Collegiate Routing Contest


Description

You may know thatBluegao University (formly Bluefly University) is famous ofnetworking technology. One day, their headmaster Yuege received aspecial router, along with a task about routing table.

In this problem,routing table is a (probably) big table with several items, each itemrepresents a subnet. The router has limited function, it can onlydeal with two next-hops and one main routing table. Packets will besend to next hop A if there exists a subnet containing thedestination of the packet in the main routing table. Otherwise theywill be send to next hop B.

You may know that,IPv4 uses 32-bit (four-byte) addresses, which limits the addressspace to 4294967296 (2^32) addresses. IPv4 addresses may be writtenin any notation expressing a 32-bit integer value, for humanconvenience, they are most often written in the dot-decimal notation,which consists of four octets of the address expressed individuallyin decimal and separated by periods. But their binary notation isalso very useful. For example, IP address 128.2.142.23 can beexpressed in dot-binary notation as10000000.00000010.10001110.00010111.

A subnet is a blockof adjacent IP addresses with exactly same binary prefix, and usuallywritten as the first IP address in its address space together withthe bit length of prefix, like “202.120.224.0/24”. If an IPaddress is in the range of an subnet, we say that this subnetcontains the IP address.

Yuege’s task isto invert the behaviour of his router, make all packets currentlyrouted to hop A route to hop B, and vice versa. Also he wants to keepthe size of the main routing table as small as possible, forperformance.

In short, for agiven routing table (i.e. a bunch of subnets), we need to get its“complement”, i.e. calculate a minimum set of subnets which haveno intersection with given subnets, and their union must be the wholeIPv4 address space.

Remember thatBluegao University is famous of networking tech, as headmaster ofBluegao University, Yuege definitely knows how to solve such problem,but he is too lazy to code, so he turns to you for help.


Input

The first line ofthe input gives the number of test cases, T. T

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值