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