from collections import defaultdict
n,m,k=map(int,input().split())
friend=defaultdict(set)
dui=defaultdict(set)
for i in range(m):
a,b,c=map(int,input().split())
if c==1:
friend[a].add(b)
friend[b].add(a)
else:
dui[a].add(b)
dui[b].add(a)
for i in range(k):
a,b=map(int,input().split())
flag=0
if a in friend[b]:
flag=1
else:
for j in friend[b]:
if a in friend[j]:
flag=2
break
if flag==1 and a not in dui[b]:
print("No problem")
elif flag==0 and a not in dui[b]:
print("OK")
elif flag==2 and a in dui[b]:
print("OK but...")
elif a in dui[b]:
print("No way")
【天梯】python L2-010 排座位 (25 point(s))
最新推荐文章于 2024-05-26 09:53:50 发布