n | """ | n | |
| Ввести две строки и проверить, содержится ли вторая в первой, с учётом того, что символы второй строки могут находиться в первой на некотором равном расстоянии друг от друга. Вывести YES или NO. | | |
| """ | | |
| main = input() | | |
| st = input() | | str = input() |
| | | sub = input() |
| if len(st) >= 2 and st[0] in main and (st[1] in main): | | if len(sub) >= 2 and sub[0] in str and (sub[1] in str): |
| index_1 = 0 | | index_1 = 0 |
| st_in_main = False | | st_in_main = False |
| enum = False | | enum = False |
| while not st_in_main and (not enum): | | while not st_in_main and (not enum): |
n | index_1 += main[index_1:].index(st[0]) | n | index_1 += str[index_1:].index(sub[0]) |
| index_2 = main[index_1:].index(st[1]) | | index_2 = str[index_1:].index(sub[1]) |
| st_in_main = st in main[index_1:len(main):index_2] | | st_in_main = sub in str[index_1:len(str):index_2] |
| while not st_in_main and (not enum): | | while not st_in_main and (not enum): |
| ind = index_2 + index_1 + 1 | | ind = index_2 + index_1 + 1 |
n | if st[1] in main[ind:]: | n | if sub[1] in str[ind:]: |
| index_2 = ind + main[ind:].index(st[1]) - 1 | | index_2 = ind + str[ind:].index(sub[1]) - 1 |
| st_in_main = st in main[index_1:len(main):index_2 - index_1] | | st_in_main = sub in str[index_1:len(str):index_2 - index_1] |
| else: | | else: |
| enum = True | | enum = True |
| index_1 += 1 | | index_1 += 1 |
n | if not st_in_main and st[0] in main[index_1:]: | n | if not st_in_main and sub[0] in str[index_1:]: |
| enum = False | | enum = False |
| else: | | else: |
| enum = True | | enum = True |
| if st_in_main: | | if st_in_main: |
| print('YES') | | print('YES') |
| else: | | else: |
| print('NO') | | print('NO') |
n | elif len(st) == 1: | n | elif len(sub) == 1: |
| if st[0] in main: | | if sub[0] in str: |
| if main.index(st[0]): | | if str.index(sub[0]): |
| print('YES') | | print('YES') |
| else: | | else: |
| print('NO') | | print('NO') |
t | elif len(st) == 0: | t | elif len(sub) == 0: |
| print('YES') | | print('YES') |
| else: | | else: |
| print('NO') | | print('NO') |