Волков-Рарог Артём Александрович, 516 группа MroC3 10702
Хуторной Дмитрий, 516 MroC3 10675
t1def merge(*lins):t1def merge(*lins):
2    merged = list()2    merged = list()
3    class_lins = lins3    class_lins = lins
4    st_pos = 04    st_pos = 0
5    while class_lins:5    while class_lins:
6        start_el = class_lins[st_pos][0]6        start_el = class_lins[st_pos][0]
7        n = len(class_lins)7        n = len(class_lins)
8        for i in range(n):8        for i in range(n):
9            if start_el in class_lins[i] and class_lins[i].index(start_el) != 0:9            if start_el in class_lins[i] and class_lins[i].index(start_el) != 0:
10                st_pos += 110                st_pos += 1
11                if st_pos == n:11                if st_pos == n:
12                    return []12                    return []
13                start_el = class_lins[st_pos][0]13                start_el = class_lins[st_pos][0]
14                break14                break
15        else:15        else:
16            merged += [start_el]16            merged += [start_el]
17            for i in range(n):17            for i in range(n):
18                if start_el in class_lins[i]:18                if start_el in class_lins[i]:
19                    class_lins[i].remove(start_el)19                    class_lins[i].remove(start_el)
20            class_lins = list(filter(None, class_lins))20            class_lins = list(filter(None, class_lins))
21            st_pos = 021            st_pos = 0
22    return merged22    return merged
2323
24def linearize(C1, *args):24def linearize(C1, *args):
25    if len(args) == 1 and (not args[0]):25    if len(args) == 1 and (not args[0]):
26        return [C1]26        return [C1]
27    merged = merge(*args)27    merged = merge(*args)
28    return [C1] + merged if merged else None28    return [C1] + merged if merged else None
29linearizations = dict()29linearizations = dict()
30s = input()30s = input()
31while s:31while s:
32    if s.startswith('class '):32    if s.startswith('class '):
33        s = s.replace('class ', '')33        s = s.replace('class ', '')
34        s = s.replace(' ', '')34        s = s.replace(' ', '')
35        if '(' in s:35        if '(' in s:
36            class_name = s[:s.index('(')]36            class_name = s[:s.index('(')]
37            inherit_from = s[s.index('(') + 1:s.index(')')]37            inherit_from = s[s.index('(') + 1:s.index(')')]
38            inherit_from.replace(' ', '')38            inherit_from.replace(' ', '')
39            if not inherit_from:39            if not inherit_from:
40                inherit_from = []40                inherit_from = []
41            else:41            else:
42                inherit_from = inherit_from.split(',')42                inherit_from = inherit_from.split(',')
43            linearization = linearize(class_name, *[linearizations[key].copy() for key in inherit_from], inherit_from)43            linearization = linearize(class_name, *[linearizations[key].copy() for key in inherit_from], inherit_from)
44            if not linearization:44            if not linearization:
45                print('No')45                print('No')
46                break46                break
47            linearizations[class_name] = linearization47            linearizations[class_name] = linearization
48        else:48        else:
49            class_name = s[:s.index(':')]49            class_name = s[:s.index(':')]
50            linearizations[class_name] = [class_name]50            linearizations[class_name] = [class_name]
51    s = input()51    s = input()
52else:52else:
53    print('Yes')53    print('Yes')
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op