QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#97448#3614. Math TradeshushuCompile Error//Python2562b2023-04-16 20:21:002023-04-16 20:21:04

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-16 20:21:04]
  • Judged
  • [2023-04-16 20:21:00]
  • Submitted

answer

n = int(input())
graph = {}

# Build the graph
for i in range(n):
name, has, wants = input().split()
graph[name] = wants

# Find the longest path
        def dfs(node, visited):
visited.add(node)
if node not in graph:
return 0
next_node = graph[node]
if next_node in visited:
return 0
return 1 + dfs(next_node, visited)

max_length = 0
for start_node in graph.keys():
        visited = set()
length = dfs(start_node, visited)
max_length = max(max_length, length)

if max_length == 0:
print("No trades possible")
else:
print(max_length)

詳細信息

Sorry: IndentationError: expected an indented block (answer.code, line 6)