[Solution] GP1. Optimal Graph Partition for Fast Routing (GP1)
[solution] GP1. Optimal Graph Partition for Fast Routing (GP1)
In computer networks, the Internet Protocol (IP) uses path routing. With path routing, the packet contains only the destination address; routers decide which "next hop" to forward each packet on to get it closer to its destination. Each router makes this decision locally, based only on the destination address and its local configuration. One way to store this configuration is to use routing tables, which means for each router, we store the "next hop" for every possible destination. However, as the scale of the network grows larger, the size of the router table grows as well. It is a big issue since routers only have limited computing resources. One way to address this issue is to divide the graph into several partitions.
We can further merge into a single node . Then for , we need to store only entries in its routing table. For routers in or , it only needs to store entries. Your task is to find an optimal partition of the initial graph to minimize the maximum size of the routing table for all routers in the network.
A computer network under consideration is an undirected connected graph , where , , ,
A partition of the network is a set of non-empty subsets of such that every node belongs to exactly one of these subsets, and the induced sub-graph for each subset in is connected. Here, one subset corresponds to one abstract node mentioned above.
Formally, is a valid partition if and only if is a family of sets that satisfies:
- , the induced subgraph is connected
The routing table size of any node for the corresponding partition is defined by the following equation:
The set of free edges of the partition are those edges that are not part of the merged nodes, that is, those edges that connect the merged nodes. is the weight of the edge .
In this subtask, it is necessary to solve a narrowed bi-criteria optimization problem:
- Find an optimal partition P, which minimizes:
- Among all the solutions to criteria 1, choose the partition P that maximizes the total weight of free edges:
The score for SubTask1 for the graph is calculated by the formula:
The final score for SubTask1 is calculated according to the following formula:
The first line contains two integers and — the number of nodes and edges, respectively.
Each of the next lines contains three integers and (), denoting an edge between the node and with weight . is the edge with index in the edge set . It is guaranteed that the input graph is connected and there are no multiple edges. That is, any pair (in any order) of nodes appear in this list no more than once.
[solution] GP1. Optimal Graph Partition for Fast Routing (GP1)
In the first line, output the number of subsets in your partition .
The -th line should begin with a single number — the size of the -th subset, followed by numbers, denoting the node IDs in the -th subset.
During the coding phase, your solutions are tested against pre-tests only. The first of them are open and available for download at the link problem-gp1-open-testset.zip in the "contest materials" section in a sidebar.
After the end of the coding phase, the last submission that scored a positive number of points on the pre-tests will be selected. It will be retested in the final tests. The rest of your submissions will be ignored. The final tests are secret and not available to the participants, they are mostly realistic. The result obtained on the final tests is your final official result for this problem.
- According to the formula, the solution with a larger score wins.
- If two solutions have the same score, the solution submitted first wins.
- For multiple test cases, the ranking is performed based on the following formula:
- Final formula for the "ICPC 2022 Online Challenge powered by HUAWEI - Problem 1":
4 4 0 1 10 2 3 12 0 2 2 2 1 1
3 1 0 2 1 2 1 3
4 4 0 1 1100 2 3 1120 0 2 1020 2 1 1010
3 1 0 2 1 2 1 3
In the first test case the graph is divided into three subsets: , , and , hence , .
As is maximum among all nodes.
And edges are free edges of partition . is not a free edge since nodes 2 and 1 are in the same subset from .From the formula we have:
In the second test case the input graph is almost the same except the edge weights.
So the maximum is unchanged and the weight sum of free edges increased.
The for the output will be points.
Comments
Post a Comment