39 lines
889 B
Python
39 lines
889 B
Python
|
|
"""
|
||
|
|
name: Nicholas Tamassia
|
||
|
|
|
||
|
|
Honor Code and Acknowledgments:
|
||
|
|
|
||
|
|
This work complies with the JMU Honor Code.
|
||
|
|
|
||
|
|
Comments here on your code and submission.
|
||
|
|
"""
|
||
|
|
|
||
|
|
|
||
|
|
def independent_set(proposed_set: set[int], graph: dict[int, set[int]]) -> bool:
|
||
|
|
for vertex in proposed_set:
|
||
|
|
for adjecent in graph[vertex]:
|
||
|
|
if adjecent in proposed_set:
|
||
|
|
return False
|
||
|
|
|
||
|
|
return True
|
||
|
|
|
||
|
|
|
||
|
|
# All modules for CS 412 must include a main method that allows it
|
||
|
|
# to imported and invoked from other python scripts
|
||
|
|
def main():
|
||
|
|
n = int(input())
|
||
|
|
|
||
|
|
graph: dict[int, set[int]] = {}
|
||
|
|
|
||
|
|
for _ in range(n):
|
||
|
|
vertecies = list(map(int, input().split()))
|
||
|
|
graph[vertecies[0]] = set(vertecies[1:])
|
||
|
|
|
||
|
|
proposed_set = set(map(int, input().split()))
|
||
|
|
|
||
|
|
print("TRUE" if independent_set(proposed_set, graph) else "FALSE")
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
main()
|