寒风信道的最大流量
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
Problem Description
Muxue youth arrives at the Wind Layer of the Ice Crystal Labyrinth, which is a massive three-dimensional ventilation duct system. Each duct has a fixed airflow capacity limit, and Muxue youth needs to establish a maximum airflow channel from the source to the sink in the network.
This duct system has a special property: some ducts have a "bidirectional regulation" function, where their airflow direction can be dynamically changed, but the total flow is limited. Additionally, the connection points (nodes) between ducts also have capacity limits, and each node can only pass a certain amount of airflow.
Given a three-dimensional airflow network with nodes and ducts, the network has the following characteristics:
-
Node Capacity
Each node has a capacity , representing the maximum total airflow that can pass through the node per unit time. -
Duct Properties
Each duct connects two nodes and , with:- Base capacity : The maximum airflow that can pass per unit time.
- Adjustment coefficient (): If airflow flows from to , the actual available capacity is ; if from to , the actual available capacity is .
- Maintenance status (0 or 1): indicates the duct is under maintenance and can only pass 50% of its original capacity.
-
Special Rules
- Airflow must satisfy flow conservation (except at the source and sink).
- The total flow passing through a node cannot exceed its capacity.
- The actual capacity of each duct is:
$\min(cap \times factor \times (s==1 \ ? \ 0.5 : 1), \text{remaining node capacity})$
Now, given the source and sink , along with operations and queries: (1) Update operation: Change the maintenance status of a duct. (2) Query operation: Ask for the maximum flow from to in the current network.
You need to process all operations and queries.
Input Format
The input contains multiple test cases. The first line contains an integer (), indicating the number of test cases.
The format for each test case is as follows:
- The first line contains four integers (, , , ).
- The second line contains integers ().
- The next lines each contain four integers (, , , ; the actual value is the input value divided by 100).
- The next line contains an integer ().
- The next lines each represent an operation or query:
- Operation:
1 xmeans toggling the maintenance status of duct (). - Query:
2means asking for the current maximum flow.
- Operation:
Note: Initially, the maintenance status for all ducts.
Output Format
For each query, output a real number on a line, representing the current maximum flow, accurate to six decimal places.
If the source cannot output or the sink cannot input due to node capacity limitations, output "0.000000".
Sample Input
1
4 5 1 4
10 5 8 12
1 2 8 50
1 3 6 30
2 3 4 70
2 4 10 20
3 4 7 60
5
2
1 3
2
1 5
2
Sample Output
5.800000
5.200000
4.100000
Sample Explanation
Initial state:
- Duct 1: 1→2 capacity 8×0.5=4.0, 2→1 capacity 8×0.5=4.0
- Duct 2: 1→3 capacity 6×0.3=1.8, 3→1 capacity 6×0.7=4.2
- Duct 3: 2→3 capacity 4×0.7=2.8, 3→2 capacity 4×0.3=1.2
- Duct 4: 2→4 capacity 10×0.2=2.0, 4→2 capacity 10×0.8=8.0
- Duct 5: 3→4 capacity 7×0.6=4.2, 4→3 capacity 7×0.4=2.8
After considering node capacity limitations, calculate the maximum flow.
Data Range and Constraints
Subtask 1 (20 points)
- , , , all
Subtask 2 (30 points)
- , , , no node capacity limitations (all )
Subtask 3 (30 points)
- , ,
Subtask 4 (20 points)
- No additional restrictions
For all data
- The total sum of across all test cases does not exceed
- The total sum of across all test cases does not exceed
- Capacities and coefficients may result in a maximum flow of 0
- High output precision is required; it is recommended to use double and retain sufficient decimal places
Hint
- This is a maximum flow problem with node capacities.
- Node capacities can be handled by splitting each node into an incoming node and an outgoing node.
- Dynamic modifications require efficient updates to the maximum flow.
- Consider using the Dinic algorithm or the ISAP algorithm.
【XJS-C5-Div2】XJSOI 春节大月赛 Round 3 & 勰码可达鸭合作赛 Round 1
- 状态
- 已结束
- 规则
- IOI
- 题目
- 5
- 开始于
- 2026-2-14 0:00
- 结束于
- 2026-2-17 0:00
- 持续时间
- 5 小时
- 主持人
- 参赛人数
- 4