CF1576A.Communication Routing Challenge
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
In optical communication networks, appropriate path planning can improve the utilization of communication resources and bring a smooth communication experience to users. The following figure shows an inter-satellite optical communication network. User messages are sent from one terrestrial base station (nodes 4 to 7) and transmitted through satellites (nodes 0 to 3) in space to another terrestrial base station (nodes 4 to 7).

In the preceding figures, there are communication connections (edges for short) between base stations and satellites and between satellites. The base stations and satellites are referred to as nodes.
User messages are transmitted on these edges and referred to as flows. Some users may make video calls with friends, and some users may send short messages to their family members. Therefore, the message traffic (called flow rate) of each user differs.
There are many parallel edges (for example, edges 0, 1, and 2) between two nodes, and the capacity of each edge also differs. Larger capacity indicates that more user messages can be transmitted, as well as shorter transmission distance indicates lower latency and better communication quality.
Nodes also have their internal structure. As shown below, some edges inside a node cannot communicate with each other because these edges (constrained edge pair) are not fully connected. For example, edge 5 and edge 7 inside node 2 cannot communicate with each other, and therefore flows cannot pass through node 2 by traversing the two unconnected edges.

Now, in the input network, the source node, target node, and required flow rate for each user flow are specified. Because network resources are limited, paths may not be successfully calculated for all user flows. We hope that you can provide a solution with the highest score.
Note, that
- all edges are undirected, so flows may come in both directions,
- edges has both capacity and length (named distance),
- several flows may use the same edge,
- flows may come through the same edge in opposite directions simultaneously,
- for the purpose of this problem, there is no difference between satellites and base stations, so flows may come through several base stations before reaching the destination station.
Constraints
- The capacity of each edge is limited. The total rate of all flows carried by an edge cannot exceed the capacity of the edge. The capacity limits the total flows in both directions.
- The calculated flow path does not allow loops or cycles.
- Due to the hardware limitation inside satellites, the number of flows passing through a node (including source and target node) cannot exceed the site flow limit (SFL) of the node. The value of SFL is 200.
- There are multiple parallel edges between two nodes, which may belong to different groups. Links in each group are managed by the same chip on a node, and there is a group flow limit (GFL). The total number of different flows on all the edges in a group cannot exceed the GFL of the group. The value of GFL is 100.
- By default, all edges are connected to each other in each node. But there are some constrained edge pairs — the pairs of edges inside specified nodes that cannot communicate with each other.
- You can make no more than 2 submissions on each 5 minutes interval.
在光通信网络中,合理的路径规划可以提高通信资源的利用率,并为用户提供流畅的通信体验。下图展示了一个星间光通信网络:用户消息从一个地面基站(节点 4 至 7)发出,经由空间中的卫星(节点 0 至 3)中转,最终抵达另一个地面基站(节点 4 至 7)。

在上述图中,地面基站与卫星之间、以及卫星与卫星之间存在通信连接(简称为边)。地面基站和卫星统称为节点。
用户消息在这些边上进行传输,称为流(flow)。部分用户可能与朋友进行视频通话,另一些用户则可能向家人发送短消息,因此每位用户的业务流量(称为流速率,flow rate)各不相同。
两个节点之间可能存在多条平行边(例如边 0、1 和 2),且每条边的容量也各不相同。容量越大,表示可承载的用户消息越多;同时,传输距离越短,意味着时延越低,通信质量越好。
节点内部也具有特定结构。如下图所示,由于某些边(称为受限边对,constrained edge pair)在节点内部未完全连通,导致它们彼此之间无法通信。例如,在节点 2 内部,边 5 与边 7 无法相互通信,因此流无法通过节点 2 同时经过这两条互不连通的边。

现在,在输入网络中,每个用户流的源节点、目标节点及所需流速率均已指定。由于网络资源有限,并非所有用户流都能成功计算出可行路径。我们希望你提供一个得分最高的解决方案。
注意:
- 所有边均为无向边,因此流可在两个方向上任意传输;
- 每条边既有容量(capacity),也有长度(称为 distance);
- 多个流可共享同一条边;
- 多个流可在同一条边上同时沿相反方向传输;
- 就本题而言,卫星与地面基站并无本质区别,因此流可在抵达目标基站前,途经多个地面基站。
约束条件
- 每条边的容量有限:一条边上承载的所有流的总速率(含两个方向)不得超过该边的容量;
- 计算所得的流路径中不允许存在环路或回路;
- 受卫星硬件限制,经过任一节点(包括源节点和目标节点)的流数量(即经过该节点的流数)不得超过该节点的站点流限制(SFL)。SFL 的值为 200;
- 两个节点之间可能存在多条平行边,这些边可能属于不同组。每组内的链路由节点上的同一芯片管理,并受组流限制(GFL)约束:一组内所有边上承载的不同流的总数不得超过该组的 GFL。GFL 的值为 100;
- 默认情况下,每个节点内部所有边彼此连通;但存在若干受限边对——即在指定节点内部,某些边对彼此之间无法通信;
- 每 5 分钟时间间隔内,最多允许提交 2 次。
输入格式
The first line contains four integers separated by space: NodeCount, EdgeCount, ConstrainedCount, and FlowCount.
- 8≤NodeCount≤1400,
- 15≤EdgeCount≤15000,
- 3≤ConstrainedCount≤3600,
- 1≤FlowCount≤14000.
The next EdgeCount lines contain information about the network. Each line contains six integers: EdgeID, GroupID, StartNodeID, EndNodeID, Distance, and Capacity.
- 0≤EdgeID<EdgeCount,
- 0≤GroupID≤4500,
- 0≤StartNodeID,EndNodeID<NodeCount,
- StartNodeID=EndNodeID,
- 100≤Distance≤10000,
- 1<Capacity≤105.
It's guaranteed that only multiple edges may share the same GroupID.
The next ConstrainedCount lines contain information about the edge pairs that are not connected in the specified nodes of the network. All other edges are connected to each other by default. Each line contains three integers: NodeID, EdgeID1, and EdgeID2.
- 0≤NodeID<NodeCount,
- 0≤EdgeID1,EdgeID2<EdgeCount,
- EdgeID1=EdgeID2.
The next FlowCount lines contain information about the flows to be calculated. Each line contains four integers: FlowID, SourceNode, TargetNode, and FlowRate.
- 0≤FlowID<FlowCount,
- 0≤SourceNode,TargetNode<NodeCount,
- SourceNode=TargetNode,
- 2≤FlowRate≤12000
Don't forget that the SFL and GFL mentioned above are also important parameters.
For the simplicity, both EdgeID and FlowID of the i-th (0-indexed) edge (flow) is always equal to i.
第一行包含四个以空格分隔的整数:NodeCount、EdgeCount、ConstrainedCount 和 FlowCount。
- 8≤NodeCount≤1400,
- 15≤EdgeCount≤15000,
- 3≤ConstrainedCount≤3600,
- 1≤FlowCount≤14000。
接下来的 EdgeCount 行描述网络中的边信息。每行包含六个整数:EdgeID、GroupID、StartNodeID、EndNodeID、Distance 和 Capacity。
- 0≤EdgeID<EdgeCount,
- 0≤GroupID≤4500,
- 0≤StartNodeID,EndNodeID<NodeCount,
- StartNodeID=EndNodeID,
- 100≤Distance≤10000,
- 1<Capacity≤105。
保证仅有多重边可能共享相同的 GroupID。
接下来的 ConstrainedCount 行描述网络中指定节点上不连通的边对信息。其余所有边默认彼此连通。每行包含三个整数:NodeID、EdgeID1 和 EdgeID2。
- 0≤NodeID<NodeCount,
- 0≤EdgeID1,EdgeID2<EdgeCount,
- EdgeID1=EdgeID2。
接下来的 FlowCount 行描述待计算的流信息。每行包含四个整数:FlowID、SourceNode、TargetNode 和 FlowRate。
- 0≤FlowID<FlowCount,
- 0≤SourceNode,TargetNode<NodeCount,
- SourceNode=TargetNode,
- 2≤FlowRate≤12000。
请勿忘记,前述提到的 SFL 和 GFL 同样是重要参数。
为简化起见,第 i 个(0-索引)边(流)的 EdgeID(FlowID)恒等于 i。
输出格式
In the first line, output the number of your success flows.
Next, each line output edge information about the path that a flow passes through.
The format is as follows: FlowID EdgeID1 EdgeID2 EdgeID3 … EdgeIDn.
There is no requirement on the output sequence between flow paths, but edges in one flow must be outputted in order, from source node to target node. Please output all successfully calculated flow paths. For other flows that are not output, the checker determines that you have not found appropriate paths for the flows by default.
第一行输出成功流的数量。
接下来,每一行输出一条流所经过的边的信息。
格式如下:FlowID EdgeID1 EdgeID2 EdgeID3 … EdgeIDn。
不同流路径之间的输出顺序没有要求,但同一条流中的边必须按从源节点到目标节点的顺序输出。请输出所有成功计算出的流路径。对于未输出的其他流,评测器默认认为你未能为其找到合适的路径。
输入输出样例
输入#1
8 15 3 1 0 0 0 1 100 1050 1 1 0 1 200 2200 2 1 0 1 200 99400 3 2 0 3 100 450 4 3 0 3 500 1120 5 4 1 2 1000 40000 6 5 2 3 600 10000 7 5 2 3 600 10000 8 6 1 4 120 2500 9 6 1 4 120 450 10 7 1 5 170 1250 11 8 2 5 200 2500 12 9 3 5 100 1250 13 10 3 6 300 1150 14 11 3 7 300 1100 2 5 7 2 6 7 2 6 11 0 4 6 100
输出#1
1 0 8 0 3 13
说明/提示
The total distance of a flow path is 620 (120+100+100+300=620). (Note: 0 9 10 12 13 is also a valid output result.)
流路径的总距离为 620(120+100+100+300=620)。(注意:0 9 10 12 13 也是一个有效的输出结果。)
输入解题思路,AI测评打分。不知道怎么写?