HandShakes/warnachinka | HandShakes/Stephan | ||||
---|---|---|---|---|---|
n | 1 | x = input() | n | 1 | a = input() |
2 | y = [] | 2 | b = [] | ||
3 | if x: | 3 | if a: | ||
4 | y.append(set(eval(x))) | 4 | b.append(set(eval(a))) | ||
5 | x = input() | 5 | a = input() | ||
6 | while x: | 6 | while a: | ||
7 | x = set(eval(x)) | 7 | a = set(eval(a)) | ||
8 | mark = 0 | 8 | s = 0 | ||
9 | |||||
9 | for i in tuple(y): | 10 | for i in tuple(b): | ||
10 | if not i.isdisjoint(x): | 11 | if not i.isdisjoint(a): | ||
11 | mark += 1 | 12 | s += 1 | ||
13 | |||||
12 | if mark == 1: | 14 | if s == 1: | ||
13 | i.update(x) | 15 | i.update(a) | ||
14 | t = i | 16 | t = i | ||
15 | else: | 17 | else: | ||
16 | t.update(i) | 18 | t.update(i) | ||
t | 17 | y.remove(i) | t | 19 | b.remove(i) |
18 | if mark == 0: | 20 | if s == 0: | ||
19 | y.append(x) | 21 | b.append(a) | ||
20 | x = input() | 22 | a = input() | ||
21 | if len(y) != 1: | 23 | if len(b) != 1: | ||
24 | |||||
22 | print("NO") | 25 | print("NO") | ||
23 | else: | 26 | else: | ||
24 | print("YES") | 27 | print("YES") | ||
25 | 28 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|