QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#519290#8517. Interesting PathsSocialPandaRE 0ms0kbPython3611b2024-08-14 18:21:022024-08-14 18:21:02

Judging History

你现在查看的是最新测评结果

  • [2024-08-14 18:21:02]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [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

output:


result: