练习题帅到没朋友"/>
PATpython练习题帅到没朋友
输入样例1
3
3 11111 22222 55555
2 33333 44444
4 55555 66666 99999 77777
8
55555 44444 10000 88888 22222 11111 23333 88888
输出样例1
10000 88888 23333
输入样例2
3
3 11111 22222 55555
2 33333 44444
4 55555 66666 99999 77777
4
55555 44444 22222 11111
输出样例2
No one is handsome
amount = int(input())
#找出有朋友的人来
friends = set()
for i in range(amount):line = input().split()#朋友圈只有自己相当于没朋友if(line[0] == "1"):passelse:for people in line[1:]:friends.add(people)#print(friends)
amountOfsearch = int(input())
#存储已经查找过的人
people_searched = set()
#没有朋友的人
no_friends_list = []
#需要查找的人
want_to_search = input().split(" ")
for people in want_to_search:#如果没朋友而且没有查找过存放在结果列表中if(people not in friends and people not in people_searched):people_searched.add(people)no_friends_list.append(people)if(len(no_friends_list) == 0):print("No one is handsome")
else:print(" ".join(no_friends_list))
更多推荐
PATpython练习题帅到没朋友
发布评论