Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- def vhoj(parent, child):
- if child == ('' or []):
- return tempor
- if parent in ke.keys() and parent != child:
- for cur_child in child:
- tempor.update([cur_child])
- child = ''.join(map(str, cur_child))
- if child == '':
- return tempor
- vhoj(child, ke[child])
- #vhoj(child, ''.join(map(str, ke[child])))
- return tempor
- herit = {}
- file = open("C:\\Users\\Andrey\\PycharmProjects\\CursePython\\St.txt", 'r')
- sys.stdin = file
- clases = [input() for _ in range(int(input()))]
- herit_class = [input() for _ in range(int(input()))]
- ke = {}
- for elm in clases:
- #if elm[0] not in ke:
- nam = elm.find(':')
- if nam == -1:
- ke[elm] = []
- continue
- cur = {elm[0: nam -1]: elm[nam+1:].split()}
- ke.update(cur)
- #print(ke)
- #print(clases, herit_class)
- for couple in ke.keys():
- tempor = set()
- herit[couple] = vhoj(couple, ke[couple])
- #print(herit)
- for couple in herit_class:
- couple = couple.split()
- if couple[0] in herit[couple[1]] or couple[0] == couple[1]:
- print("Yes")
- else:
- print('No')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement