QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#519290 | #8517. Interesting Paths | SocialPanda | RE | 0ms | 0kb | Python3 | 611b | 2024-08-14 18:21:02 | 2024-08-14 18:21:02 |
answer
import networkx as nx
def max_unique_paths(graph, source, sink):
# 创建一个有向图
G = nx.DiGraph()
# 添加边,容量为1
for u in graph:
for v in graph[u]:
G.add_edge(u, v, capacity=1)
# 使用最大流算法
flow_value, flow_dict = nx.maximum_flow(G, source, sink)
return flow_value
# 示例图表示为邻接表
graph = {
1: [2, 3],
2: [4],
3: [4],
4: [5],
5: []
}
# 查找从节点 1 到节点 n 的最多路径数量
n = 5
max_paths = max_unique_paths(graph, 1, n)
print(max_paths)
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Dangerous Syscalls
input:
5 7 1 3 3 5 1 2 2 3 3 4 4 5 2 4