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