Problem:


Score : 400 points

Problem Statement

There are N squares arranged in a row, numbered 1, 2, ..., N from left to right.
You are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.

In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.

You can repeat the following operation any number of times:

Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.

You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.

Determine whether this is possible.

Constraints

4 \leq N \leq 200\ 000

S is a string of length N consisting of . and #.

1 \leq A, B, C, D \leq N

Square A, B, C and D do not contain a rock.

A, B, C and D are all different.

A < B

A < C

B < D

Input

Input is given from Standard Input in the following format:

N A B C D
S

Output

Print Yes if the objective is achievable, and No if it is not.

Sample Input 1

7 1 3 6 7
.#..#..

Sample Output 1

Yes

The objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)

A#B.#..

A#.B#..

.#AB#..

.#A.#B.

.#.A#B.

.#.A#.B

.#..#AB

Sample Input 2

7 1 3 7 6
.#..#..

Sample Output 2

No

Sample Input 3

15 1 3 15 13
...#.#...#.#...

Sample Output 3

Yes



Sample input:
7 1 3 6 7
.#..#..


Sample output:
Yes

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = [int(i) for i in input().split()]
s = input()

if d >= c:
    flag1 = False
    block = 0
    for i in range(b, len(s)):
        if block == 2:
            flag1 = False
            break
        elif i == d-1:
            flag1 = True
            break
        elif s[i] == ".":
            block = 0
        elif s[i] == "#":
            block += 1

    if flag1 == True:
        s2 = s[:d-1]+'#'+s[d:]
        flag1 = False
        block = 0
        for i in range(a, len(s)):
            if block == 2:
                flag1 = False
                break
            elif i == c-1:
                flag1 = True
                break
            elif s2[i] == ".":
                block = 0
            elif s2[i] == "#":
                block += 1

    if flag1:
        print("Yes")
    else:
        print("No")



else:
    flag2 = False
    flag3 = False
    if s[b-2]=="." or b-1==a:
        temp = 1
    else:
        temp = 0
    block = 0
    for i in range(b-1,c-1):
        if temp == 3:
            flag2 = True
            temp = i-1
            break
        elif s[i] == "#":
            temp = 0
        elif s[i] == ".":
            temp += 1

    if flag2 == True:
        flag3 = False
        block = 0
        s1 = s[:temp - 1] + '#' + s[temp:]
        for i in range(a, len(s)):
            if block == 2:
                flag3 = False
                break
            elif i == c-1:
                flag3 = True
                break
            elif s1[i] == ".":
                block = 0
            elif s1[i] == "#":
                block += 1

        if flag3 == True:
            s3 = s1[:c - 1] + '#' + s1[c:]
            flag3 = False
            block = 0
            for i in range(temp + 1, len(s)):
                if block == 2:
                    flag3 = False
                    break
                elif i == c-1:
                    flag3 = True
                    break
                elif s3[i] == ".":
                    block = 0
                elif s3[i] == "#":
                    block += 1

    if flag3:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = list(map (int, input().split()))
s = input ()

ans = True

if '##' in s[a:max(c,d)]:
    ans = False
else:
    if d < c:
        if '...' not in s:
            ans = False

if ans is True:
    print ('Yes')
else:
    print ('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
if (c<d):
	if not '##' in s[a-1:d-1]: print('Yes')
	else: print('No')
elif (d<c):
	if (not '##' in s[a-1:c-1])&('...' in s[b-2:d]): print('Yes')
	else: print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
s=input()

if C<D:
    if '##' in s[A:D]:
        print('No')
    else:
        print('Yes')
else:
    if '##' in s[A:C]:
        print('No')
    else:
        if '...' in s[B:D+1]:
            print('Yes')
        else:
            print('No')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())

S = list(input().split()[0])

result = "Yes"
flag = False

if C < B:
    for i in range(A, C - 1):
        if S[i] == "#" and S[i + 1] == "#":
                result = "No"
                print(result)
                flag = True
                break
    for i in range(B, D - 1):
        if S[i] == "#" and S[i + 1] == "#":
                result = "No"
                print(result)
                flag = True
                break

if C < D:
    for i in range(B, D - 1):
        if S[i] == "#" and S[i + 1] == "#":
                result = "No"
                print(result)
                flag = True
                break
else:
    for i in range(B, C - 1):
        if S[i] == "#" and S[i + 1] == "#":
                result = "No"
                print(result)
                flag = True
                break
    if not flag:
        for i in range(B - 1, C - 2):
            if S[i] == "." and S[i + 1] == "." and S[i + 2] == ".":
                result = "Yes"
                print(result)
                flag = True
                break
if not flag:
    print(result)

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
A -= 1
B -= 1
C -= 1
D -= 1
if A < B and B < D and A < C and S[A] == "." and S[B] == "." and S[C] == "." and S[D] == ".":
    ans = True
else:
    ans = False

if C < B:
    count_x = 0
    for i in range(A, C):
        if S[i] == "#":
            count_x += 1
        else:
            count_x = 0
        if count_x > 1:
            ans = False
            break
    if ans:
        count_x = 0
        for i in range(B, D):
            if S[i] == "#":
                count_x += 1
            else:
                count_x = 0
            if count_x > 1:
                ans = False
                break
elif C < D:
    count_x = 0
    for i in range(A, D):
        if S[i] == "#":
            count_x += 1
        else:
            count_x = 0
        if count_x > 1:
            ans = False
            break
else:
    count_x = 0
    for i in range(A, C):
        if S[i] == "#":
            count_x += 1
        else:
            count_x = 0
        if count_x > 1:
            ans = False
            break
    if ans:
        count_o = 0
        ans = False
        for i in range(B, D+2):
            if S[i] == "#":
                count_o = 0
            else:
                count_o += 1
            if count_o > 2:
                ans = True
                break
if ans:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int, input().split())
S = input()
S1 = ''

if C < D:
    S1 = S[A-1:D-1]
else:
    S1 = S[A-1:C-1]

fd = S1.find('##')
if fd != -1:
    print('No')
    exit()

if C < D:
    print('Yes')
    exit()

else:
    S2 = S[B-2:C+1]
    fddot = S2.find('...')

    if fddot == -1:
        print('No')

    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from copy import copy
import numpy as np
from numpy.fft import fft, ifft
from fractions import gcd


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

n, a, b, c, d = MAP()
s = list(input())

lis3  =[]
ct_iwa=0

tmp3 = []
tmp_iwa=[]
for i in range(n):
    #print(s[i])
    if s[i] =='.':
        tmp3.append(i)
        if len(tmp_iwa) > 1:
            ct_iwa += 1
            
        tmp_iwa.clear()
    else:
        tmp_iwa.append(1)
        if len(tmp3) > 2:
            tmp=tmp3.copy()
            lis3.append(tmp)
               
        tmp3.clear()
    
    #print(tmp3)


if len(tmp3) == 3:
    lis3.append(tmp3)
if len(tmp_iwa) > 1:
    ct_iwa += 1

#print(lis3, ct_iwa)

flag=0

if c < d:
    #print('1')
    if ct_iwa == 0:
        print('Yes')
    else:
        print('No')
else:
    #print('2')
    for x in lis3:
        if b - 1 < x[0] and x[0] < d - 1 and ct_iwa == 0:
            print('Yes')
            flag = 1
            break

    if flag == 0:
        print('No')

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int,input().split())
s = str(input())
s = s[a:max(c,d)]

l_s = []
for i in range(len(s)):
    l_s += [0 if s[i] == '.' else 1]

ans = 'Yes'
if i in range(len(s)-1):
    if sum(l_s[i:i+2])==2:
        ans = 'No'

if ans == 'Yes':
    if d>c:
        pass
    else:
        ans = 'No'
        for j in range(b-a,d-1-a):
            if sum(l_s[j:3+j]) == 0:
                ans = 'Yes'
            else:
                pass

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)
W, A, B, C, D = map(int, input().split())
S = [i for i in input()]
action = [1,2,1,2]

def dfs(x, y, field, tmp):
    if C-1 == x and D-1 == y:
        return True
    for idx, n in enumerate(action):
        if idx <= 1:
            n += x
            if n < W:
                if n == y:
                    continue
                elif field[n] == "#":
                    continue
                tmp = field[n]
                field[n] = "#"
                field[x] = tmp
                return dfs(n, y, field, tmp)
        else:
            n += y
            if n < W:
                if n == x:
                    continue
                elif field[n] == "#":
                    continue
                tmp = field[n]
                field[n] = "#"
                field[y] = tmp
                return dfs(x, n, field, tmp)
    return False


if dfs(A-1,B-1,S, "."):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())

s = input()

flagA = True
flagB = True

for i in range(d - b - 1):
    if s[b + i] == "#" and s[b + i + 1] == "#":
        flagB = False

for i in range(c - a - 1):
    if ((s[a + i] == "#") or (a + i == d - 1)) and ((s[a + i + 1] == "#") or (a + i + 1 == d - 1)):
        flagA = False
        for j in range(b, c - b - 2):
            if (s[b + j] == "." and s[b + j + 1] == "." and s[b + j + 2] == "."):
                flagA = True

if flagA and flagB:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()

# stoneCnt=S.count("#")

# if stoneCnt == 0:
# 	print("Yes")
# 	exit(0)


curStoneLen=0

# 先にBがいけるか考える
# いけなければOUT
for b in range(B-1,D):
	if S[b] == ".":
		curStoneLen = 0
	else:
		curStoneLen += 1

	if 2 == curStoneLen:
		print("No")
		exit(0)



maxAtoDSeqSpaceLen=0
curSeqSpaceLen=0


curStoneLen=0

for a in range(A-1,C):
	if S[a] == ".":
		curStoneLen = 0
		curSeqSpaceLen += 1
	else:
		curStoneLen += 1
		curSeqSpaceLen = 0

	if D < C and a < D+1:
		maxAtoDSeqSpaceLen=max(maxAtoDSeqSpaceLen,curSeqSpaceLen)

	if 2 == curStoneLen:
		print("No")
		exit(0)

# print(maxAtoDSeqSpaceLen)

if D < C and maxAtoDSeqSpaceLen < 3:
	# AはBをかわさないといけないのに、かわすスペースが無い

	print("No")
	exit(0)	
else:
	# その他の場合は、Bを無視して良い
	pass


print("Yes")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()

if '##' in S:
    print("No")
    quit()

if C > D:
    if '...' not in S[B-1:C-1]:
        print("No")
        quit()
    if S[B-1:C-1].count('...') % 2 == 0:
        print("No")
        quit()
    # if C - D == 2 and S[C - 2] == '#' and S[D - 2] == '#':
    #     print("No")
    #     quit()

print("Yes")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = (int(i) for i in input().split())  
s = str(input())
n = len(s)

m = max([c, d])
if n>m:
    n = m
    s = s[:n]
    
if '##' in s[a-1:]:
    print('No')
elif b>c:
    print('Yes')
else:
    if c>d:
        if '...' in s[b-1:d+1]:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[38]:


N, A, B, C, D = map(int, input().split())
S = input()
"""
7 1 3 7 6
.#..#..
"""


# In[39]:


ans = 'Yes'
if C<D:
    shc = 0
    for s in S[A:C+1]:
        if shc > 1:
            ans = 'No'
            break
        if s == '#':
            shc += 1
        if s == '.':
            shc = 0
    for s in S[B:D+1]:
        if shc > 1:
            ans = 'No'
            break
        if s == '#':
            shc += 1
        if s == '.':
            shc = 0
elif C>D:
    shc = 0
    dc = 0
    mdc = 0
    for s in S[A:C+1]:
        if shc > 1:
            ans = 'No'
            break
        if s == '#':
            shc += 1
            if dc>0:
                mdc = max(dc, mdc)
                dc = 0
        if s == '.':
            dc += 1
            shc = 0
    if mdc < 3:
        shc = 0
        for i, s in enumerate(S[0:A+1:-1]):
            if shc >1:
                l = A-i+1
                break
            if s == '#':
                shc += 1
            if s == '.':
                shc = 0
        else:
            l = 0
            
        for i, s in enumerate(S[C:]):
            if shc >1:
                r = C+i
                break
            if s == '#':
                shc += 1
            if s == '.':
                shc = 0
        else:
            r = N
        
        mdc = 0
        for s in S[l:r]:
            if shc > 1:
                ans = 'No'
                break
            if s == '#':
                shc += 1
                if dc>0:
                    mdc = max(dc, mdc)
                    dc = 0
            if s == '.':
                dc += 1
                shc = 0
        if mdc < 3:
            ans = 'No'
print(ans)


# In[37]:


"""
k = []
try:
    st = S.index(".")+1
except:
    print("No")
for i in range(N):
    
    if i==0:
        m = S[i]
        count = 1
    else:
        if S[i] == m:
            count += 1
        else:
            k.append(count)
            m = S[i]
            count = 1
        
    if i == A-1:
        wa = len(k)
    if i == B-1:
        wb = len(k)
    if i == C-1:
        wc = len(k)
    if i == D-1:
        wd = len(k)
    if i == N-1:
        k.append(count)

if S[i] == '.':
    dot = k[::2]
    sharp = k[1::2]
else:
    dot = k[1::2]
    sharp = k[2::2]
    wa -= 1
    wb -= 1
    wc -= 1
    wd -= 1
#print(k)
#print(dot)
#print(sharp)
#print(wa, wb, wc, wd)

if C<D:
    for s in sharp[wa//2:wc//2]:
        if s>1:
            print("No")
            sys.exit()
    for s in sharp[wb//2:wd//2]:
        if s>1:
            print("No")
            sys.exit()
    print("Yes")
elif C>D:
    for s in sharp[wa//2:wc//2]:
        if s>1:
            print("No")
            sys.exit()
    for s in sharp[wb//2:wd//2]:
        if s>1:
            print("No")
            sys.exit()
    if C<B:
        print("Yes")
        sys.exit()
    elif C>B:
        l = 0
        for i, s in enumerate(sharp[0:wa//2:-1]):
            if s>2:
                l = wa//2-i
        r = len(dot)
        for i, s in enumerate(sharp[wc//2:]):
            if s>2:
                r = wc//2+i
        for d in dot[l:r+1]:
            if d>2:
                print("Yes")
                sys.exit()
        else:
            print("No")
"""


# In[ ]:

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()

def solveSimple(s, a, b, c, d):     
    if '##' in s[b-1:d]:
        return False 
    if '##' in s[a-1:c]:
        return False
    return True

import re
def solveDifficult(s, a, b, c, d):
    spot = [m.start() for m in re.finditer('\.\.\.', s)]
    
    if len(spot) == 0:
        return False

    for i, it in enumerate(spot):
        if it > a and it > b:
            break

    exchange = [it]

    for it in exchange:
        if solveSimple(s, a, b, it, it+1) and solveSimple(s, it, it+1, c, d):
            return True
    return False

# simple 
if c < d:
    ans = solveSimple(s, a, b, c, d)
    
# solveDifficult
else:
    ans = solveDifficult(s, a, b, c, d)
    
if ans:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from sys import stdin
N, A, B, C, D = (int(i) for i in input().rstrip().split())
S = stdin.readline().rstrip()
A -= 1
B -= 1
C -= 1
D -= 1
swap_flag = False
swap_able = -1
for itr in range(len(S)):
    if itr < (len(S) - 1) and S[itr] == '#' and S[itr+1] == '#':
        print('No')
        exit()
    if swap_flag == False and 2 <= itr and S[itr] == '.' and S[itr-1] == '.' and S[itr-2] == '.':
        swap_able = itr
        swap_flag = True 
print(swap_able)
print(A, B, C, D)
if swap_able != -1:
    if A > B and C < D and S[C-1] == '#' and C <= swap_able:
        print('No')
    # elif A > B and C < D and C != N and S[C+1] == '#' and C <= swap_able:
    #     print('No')
    elif A < B and D < C and S[D-1] == '#' and D <= swap_able:
        print('No')
    # elif A < B and D < C and D != N and S[D+1] == '#' and D <= swap_able:
    #     print('No')
    else:
        print('Yes')
else:
    if A > B and C < D and S[C-1] == '#':
        print('No')
    elif A > B and C < D and C != N and S[C+1] == '#':
        print('No')
    elif A < B and D < C and S[D-1] == '#':
        print('No')
    elif A < B and D < C and D != N and S[D+1] == '#':
        print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())

S = list(input().split()[0])

result = "Yes"
flag = False

if C < B:
    for i in range(A, C - 1):
        if S[i] == "#" and S[i + 1] == "#":
                result = "No"
                print(result)
                flag = True
                break

if C < D:
    for i in range(B, D - 1):
        if S[i] == "#" and S[i + 1] == "#":
                result = "No"
                print(result)
                flag = True
                break
else:
    for i in range(B, C - 1):
        if S[i] == "#" and S[i + 1] == "#":
                result = "No"
                print(result)
                flag = True
                break
    if not flag:
        for i in range(B - 1, C - 2):
            if S[i] == "." and S[i + 1] == "." and S[i + 2] == ".":
                result = "Yes"
                print(result)
                flag = True
                break
if not flag:
    print(result)

Submission status: Wrong Answer

Solution code:
x = input().split()
s = input()
n = int(x[0])
a = int(x[1])
b = int(x[2])
c = int(x[3])
d = int(x[4])


kome_flag = False
santen_flag = False

b_s = s[a:]

if '...' in b_s:
  santen_flag = True
if not '##' in b_s:
  kome_flag = True
    
   
if c < d:
  if kome_flag:
    print('Yes')
  else:
    print('No')

if d < c:
  if kome_flag and santen_flag:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int, input().split())
S = input()
S =S+"#"
S =S+"#"
S =S+"#"
answer = 1
a = 1
distance = []
distance_2 = []
for n in range(A-1,max(C-1,D-1)):
  a += 1
  if S[n] == "#":
    distance.append(a)
    a = 0
if 1 in distance:
  answer = 0
if D < C and answer == 1:
  a = 1
  for n in range(B-2,D+3):
    a += 1
    if S[n] == "#":
      distance_2.append(a)
      a = 0
  if max(distance_2) < 4:
    answer = 0
if answer == 1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = list(input())
last = ""
for i in range(a, max(c, d)):
    if last == "#" and s[i] == "#":
        print("No")
        exit()
    last = s[i]
flag = False
if c > d:
    s[b - 1] = "#"
    for i in range(a, c):
        if last == "#" and s[i] == "#":
            flag = True
        last = s[i]
    s[b - 1] = "."
    count = 0
    for i in range(b - 1, d):
        if s[i] == ".":
            count += 1
            if count == 3:
                flag = False
        else:
            count = 0
else:
    for i in range(b, d):
        if last == "#" and s[i] == "#":
            flag = True
        last = s[i]
if not flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
S_list = list(S)
a = 0

S_rock = [s for s in S.split('.') if s ]
rock = list(set(S_rock))

if len(rock) > 1:
    a = 1

S_mass = [s for s in S.split('#') if s]
mass = list(set(S_mass))

if mass == ['.','..'] or mass == ['.'] or mass == ['..'] or mass == ['..','.']:
    b = 0
else:
    b = 1

if D < C and b == 0:
    if S_list[D - 2] == '#':
        a = 1

if a == 1:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int,input().split())
S = input()

pres = 'x'          # S[i-1]
cntx, cnty = 0, 0   # x:'.'の連続数, y:'#'の連続数
mxx, mxy = 1, 1     # mxx:'.'の連続数max, mxy:'#'の連続数max

for i in range(A-1, max(C, D)): # base=0
    if S[i] == pres:
        if S[i] == '.':
            cntx += 1
            if i >= B-1 and i < D+2:  # .のチェックは B-D+1だけ
                mxx = max(cntx, mxx)
        elif S[i] == '#':
            cnty += 1
            if C > B or (i < C and i >= B-1):   # C < B の場合は、C-Bでは#の数は不問
                mxy = max(cnty, mxy)
    else:
        pres = S[i]
        if S[i] == '.':
            cntx = 1
        elif S[i] == '#':
            cnty = 1

if C < D:
    if mxy < 2:
        print("Yes")
    else:
        print("No")
else:
    if mxy < 2 and mxx >= 3:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
#7 1 3 6 7  
#.#..#..
n,a,b,c,d = map(int,input().split())

m = list(input())

m[a-1] = "A"
m[b-1] = "B"

a_list = []
b_list = []
def a_mon(x,text):
    i = 0
    while True:
        if x+i < n:
            if m[x+i] == ".":
                m[x-1+i],m[x+i] = m[x+i],m[x-1+i]
                if x == b:
                    b_list.append(m.index(text))
                else:
                    a_list.append(m.index(text))
                i += 1
            if b+1+i<n:
                if m[x+1+i] == ".":
                    m[x-1+i],m[x+1+i] = m[x+1+i],m[x-1+i]
                    if x == b:
                        b_list.append(m.index(text))
                    else:
                        a_list.append(m.index(text))
                    i += 2
            else:
                break
        else:
            break
            
a_mon(b,"B")
a_mon(a,"A")

count = 0
for al in a_list:
    if al == c-1:
        count += 1
        break
for bl in b_list:
    if bl == d-1:
        count += 1
        break
if count == 2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = ( int(i) for i in input().split())
s = input()

a_to_c = s[a-1:c-1]
b_to_d = s[b-1:d-1]

possibility = True

if a_to_c.find("##")!=-1 or b_to_d.find("##")!=-1:
    possibility = False
if c>d:
    if not(s.find('...')!=-1):
        possibility = False

if possibility:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
#codeforces1148A_live
from collections import Counter
gi = lambda : list(map(int,input().strip().split()))
n, a, b, c, d = gi()
s = input()
if a > b:
	a, b = b, a
	c, d = d, c
a -= 1
b -= 1
c -= 1
d -= 1
if c <= d:
	temp = s[a:c]
	if "##" in temp:
		print("No")
		exit()
	temp = s[b:d]
	if "##" in temp:
		print("No")
		exit()
	print("Yes")
	exit()
temp = s[a:c]
if "##" in temp or "..." not in temp:
	print("No")
	exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
s_flag = False
can_flag = True
count = 0

for i in range(n):
  if s[i] == '#':
    count = 0
    if s_flag:
      can_flag = False
      break
    s_flag = True

  else:
    s_flag = False
    count += 1
if count <= 2:
  if c > d:
    can_flag = False

if can_flag:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D =list(map(int,input().split()))
s=input()

if "##" in s[A-1:max(C,D)]:
  print("No")
  quit()
st,e=0,0

for spl in s.split("##"):
  e += (len(spl)+2)
  if st <A<max(C,D)<=e:
    break
  st+= (len(spl)+2)

if "..." in s[B-1:min(C,D)+1] or B<C<D:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
def g(i, y, S):
    while i != y:
        if S[i + 2] == '.':
            i += 2
        elif S[i + 1] == '.':
            i += 1
        else:
            break
    return i
def dc(n, a, b, c, d, S):
    S = list(S)
    S[b] = 'B'
    while a < b:
        a = g(a, c, S)
        if S[b + 1] == '.':
            S[b] = '.'
            b += 1
            S[b] = 'B'
        elif S[b + 2] == '.':
            S[b] = '.'
            b += 2
            S[b] = 'B'
        else:
            return a == c
    return True
def solve():
    n, a, b, c, d = map(int, input().split())
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    S = input() + "##"
    if "##" in S[a + 1:c] or "##" in S[b + 1:d]:
        return False
    if c < d:
        return True
    else:
        if "##" in S[a + 1:c]:
            return False
        return dc(n, a, b, c, d, S)
    return True
print("Yes" if solve() else "No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = list(input())
for i in range(b, d - 1):
    if s[i] == '#' and s[i + 1] == '#':
        print('No')
        exit(0)
for i in range(a, c - 1):
    if s[i] == '#' and s[i + 1] == '#':
        print('No')
        exit(0)
if c < d:
    print('Yes')
else:
    l, r = a - 1, a
    while l >= 0 and (s[l] != '#' or s[l + 1] != '#'):
        l -= 1
    l += 2 - int(l == -1)
    while r < n and (s[r - 1] != '#' or s[r] != '#'):
        r += 1
    r -= 2 - int(r == n)
    for i in range(l, r - 1):
        if s[i] == '.' and s[i + 1] == '.' and s[i + 2] == '.':
            print('Yes')
            break
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(lambda x: int(x)-1,input().split())
S = input()

def obs(st,end):
  for i in range(st,end):
  	if S[i] is "#" and S[i+1] is "#": return True
  return False

if obs(B,D) or obs(A,C):
  print("No")
elif C > D:
  b = False
  for i in range(B-1,max(D,N-2)):
    if S[i] is "." and S[i+1] is "." and S[i+2] is ".":
      b = True
      break
  if b:
    print("Yes")
  else:
    print("No")
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int, input().split())
s = input()

flag3 = 0
flagno = 0

if c > d:

    for i in range(a,c-3):

        if s[i:i+2] == "##":
            flagno += 1
            break

    if flagno == 0:

        for i in range(b,d):
        
            if s[i-2:i+1] == "...":
                flag3 += 1
                break
    
    if flagno == 0 and flag3 > 0:
        print("Yes")

    else:
        print("No")

else:

    for i in range(a,c-3):

        if s[i:i+2] == "##":
            flagno += 1
            break

    for i in range(b,d-3):

        if s[i:i+2] == "##":
            flagno += 1
            break
    
    if flagno == 0:
        print("Yes")

    else:
        print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin, exit

N, A, B, C, D = [int(x) for x in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip()
for k in range(A - 1, max(D, C)):
    if S[k] == '#' and S[k + 1] == '#':
        print('No')
        exit()

if C < D:
    print('Yes')
else:
    cnt = 0
    for k in range(B - 2, D):
        if S[k] == '.':
            cnt += 1
        else:
            cnt = 0
        if cnt > 2:
            print('Yes')
            exit()
    print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int, input().split())
S=input()
result = ""

for i in range(len(S)):
    if S[i:i+2]=="##":
        print("No")
        break

if result == "":
    if C < D:
        result ="Yes"
    else: # D < C
        if S[B-2] == "." and S[B] == ".":
            result = "Yes"
        else:
            for i in range(B-2,D-5):
                if S[i:i+5] == "#...#":
                    result = "Yes"

if result == "":
    result = "No"

print(result)

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())

def mymain(s):
    for i, p in list(enumerate(s))[a-1:c]:
        if p == "#" and s[i+a] == "#":
            return 'No'
    if c > d:
        flg = "No"
        if s[b] == "." and s[b-2] == "." or s[b] == "." and s[b+1] == ".":
                flg = 'Yes'
        else:
            for i, s_b_d_point in list(enumerate(s))[b-1:d]:
                if i+b+1 < len(s) and i+b+2 < len(s) and s_b_d_point == '.' and s[i+b+1] == '.' and s[i+b+2] == '.':
                    flg = "Yes"
        return flg
    return 'Yes'
                
print(mymain(input()))

Submission status: Wrong Answer

Solution code:
# coding: UTF-8
# sample code

v = list(map(int, input().split()))
n, a, b, c, d = v[0], v[1], v[2], v[3], v[4]
s = input()

ac_cnt_1, ac_max_1 = 0, 0
bd_cnt_1, bd_max_1 = 0, 0
bd_cnt_0, bd_max_0 = 0, 0

s_tmp = ''
for i in range(n):
	if i+1 == b:
		s_tmp += '#'
	else:
		s_tmp += s[i]
for i in range(c-a):
	if s_tmp[i+a-1] == '#':
		ac_cnt_1 += 1
		if ac_max_1 < ac_cnt_1:
			ac_max_1 = ac_cnt_1
	else:
		ac_cnt_1 = 0
for i in range(d-b):
	if s[i+b-1] == '#':
		bd_cnt_0 = 0
		bd_cnt_1 += 1
		if bd_max_1 < bd_cnt_1:
			bd_max_1 = bd_cnt_1
	else:
		bd_cnt_0 += 1
		bd_cnt_1 = 0
		if bd_max_0 < bd_cnt_0:
			bd_max_0 = bd_cnt_0
if c < b:
	if (ac_max_1 <= 1) and (bd_max_1 <= 1):
		print('Yes')
	else:
		print('No')
elif c < d:
	if (ac_max_1 <= 1) and (bd_max_1 <= 1):
		print('Yes')
	else:
		print('No')
else:
	if (ac_max_1 <= 1) and (bd_max_1 <= 1) and (bd_max_0 >= 3):
		print('Yes')
	else:
		print('No')

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int,input().split())
s = input()

if '##' in s:
    print('No')
elif c < d:
    print('Yes')
elif not '...' in s:
    print('No')
else:
    i = -1
    while True:
        i = s.find('...', i+1)
        if b <= i + 1 < d -1 :
            print('Yes')
            break
        elif i + 1 >= d:
            print('No')
            break
        else:
            pass

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
a-=1
b-=1
c-=1
d-=1

temp=str(input())
maxim=max(a,b)
if temp[maxim:].count("...")!=0 or temp[maxim+1]==temp[maxim+2]=="." or temp[maxim+1]==temp[maxim-1]==".":
    flag=1
else:
    flag=0
    
s=list(temp)
s[a]="A"
s[b]="B"
s[c]="C"
s[d]="D"

ans=1

for i in range(n-1):
    if s[i]==s[i+1]=="#":
        ans=0
        

if c<d and ans==1:
    ans=1
elif c>d and ans==1:
    if flag==1:
        ans=1
    elif s[d-1]=="#" or s[d+1]=="#":
        ans=0
    else:
        ans=1
                
if ans==1:
    print("Yes")
else:
    print("No")