Algorithm
우물 안 개구리
Roiei
2021. 9. 29. 13:35
반응형
g = collections.defaultdict(dict)
for u, v in relations:
g[u][v] = 1
g[v][u] = 1
visited = set()
cnt = 0
for node in range(1, N + 1):
val = weights[node - 1]
if len(g[node].items()) == 0:
cnt += 1
continue
for v, w in g[node].items():
if val <= weights[v - 1]:
break
else:
cnt += 1
print(cnt)
반응형