QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#97448 | #3614. Math Trade | shushu | Compile Error | / | / | Python2 | 562b | 2023-04-16 20:21:00 | 2023-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
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [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)
Details
Sorry: IndentationError: expected an indented block (answer.code, line 6)