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 = map(lambda x: int(x) - 1, input().split())
s = input()

if c < d:
    if "##" in s[a:d]:
        print("No")
    else:
        print("Yes")
else:
    if "##" in s[a:c] or "..." not in s[b:d]:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

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

if c < d:
    if "##" in s[a:d]:
        print("No")
    else:
        print("Yes")
else:
    if "##" in s[a:c] or "..." not in s[a:c]:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

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

if c < d:
    if "##" in s[a:]:
        print("No")
    else:
        print("Yes")
else:
    if "##" in s[a:] or "..." not in s[a:]:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def cd(a, b, c, d, s):
    for i in range(len(s)):
        if a < i+1 < d and s[i] + s[i + 1] == "##":
            return "No"
    return "Yes"


def dc(a, b, c, d, s):
    flag = False
    for i in range(len(s)):
        if a < i + 1 < c and s[i] + s[i + 1] == "##":
            return "No"
        if b <= i + 1 <= d and s[i] + s[i + 1] + s[i + 2] == "...":
            flag = True
    if flag:
        return "Yes"
    else:
        return "No"


if __name__ == "__main__":
    n, a, b, c, d = map(int, input().split())
    s = input()+"##"

    if c < d:
        ans = cd(a, b, c, d, s)
    else:
        ans = dc(a, b, c, d, s)
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
N,A,B,C,D = map(int, input().split())
S = input()
NG = N+3
OOmin = N+2
OOmax = 0
for i in range(N-1):
  if S[i] == S[i+1] == '#':
    if i+1 < C or i+1 < D:
      print("No")
      sys.exit()
    if i+1 > A:
      print("No")
      sys.exit()
if C>D:
  for i in range(N-2):
    if S[i] == S[i+1] == S[i+2] == '.':
      if B <= i+2 <= D:
        break
    if i == N-3:
      print("No")
      sys.exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
N,A,B,C,D = map(int, input().split())
S = input()
NG = N+3
OOmin = N+2
OOmax = 0
for i in range(N-1):
  if S[i] == S[i+1] == '#':
    if i+1 < C or i+1 < D:
      print("No")
      sys.exit()
    if i+1 > A:
      print("No")
      sys.exit()
for i in range(N-2):
  if S[i] == S[i+1] == S[i+2] == '.':
    if C>D and (i+2 > D or i+2 < B):
      if i == N-3:
        print("No")
        sys.exit()
    else:
      break
  elif C>D:
    if i == N-3:
      print("No")
      sys.exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
N,A,B,C,D = map(int, input().split())
S = input()
NG = N+3
OOmin = N+2
OOmax = 0
for i in range(N-1):
  if S[i] == S[i+1] == '#':
    if i+1 < C or i+1 < D:
      print("No")
      sys.exit()
    if i+1 > A:
      print("No")
      sys.exit()
for i in range(N-2):
  if S[i] == S[i+1] == S[i+2] == '.':
    if C>D and (i+2 > D or i+2 < B):
      if i == N-3:
        print("No")
        sys.exit()
    else:
      break
  else:
    if i == N-3:
      print("No")
      sys.exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
N,A,B,C,D = map(int, input().split())
S = input()
NG = N+3
OOmin = N+2
OOmax = 0
for i in range(N-1):
  if S[i] == S[i+1] == '#':
    if i+1 < C or i+1 < D:
      print("No")
      sys.exit()
    if i+1 > A:
      print("No")
      sys.exit()
for i in range(N-2):
  if S[i] == S[i+1] == S[i+2] == '.':
    if C>D and (i+2 > D or i+2 < B):
      if i == N-3:
        print("No")
        sys.exit()
    else:
      break
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
N,A,B,C,D = map(int, input().split())
S = input()
NG = N+3
OOmin = N+2
OOmax = 0
for i in range(N-1):
  if S[i] == S[i+1] == '#':
    if i+1 < C or i+1 < D:
      print("No")
      sys.exit()
    if i+1 > A:
      print("No")
      sys.exit()
for i in range(N-2):
  if S[i] == S[i+1] == S[i+2] == '.':
    OOmin = min(OOmin, i+2)
    OOmax = max(OOmax, i+2)
if C>D and (OOmin > D or OOmax < B):
  print("No")
  sys.exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
N,A,B,C,D = map(int, input().split())
S = input()
NG = N+3
OOmin = N+2
OOmax = 0
for i in range(N-1):
  if S[i] == S[i+1] == '#':
    NG = i+1
    break
if NG<C or NG<D:
  print("Yes")
  sys.exit()
for i in range(N-2):
  if S[i] == S[i+1] == S[i+2] == '.':
    OOmin = min(OOmin, i+2)
    OOmax = max(OOmax, i+2)
if C>D and (OOmin > D or OOmax < B):
  print("No")
  sys.exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
N,A,B,C,D = map(int, input().split())
S = input()
NG = N+3
OO = 0
for i in range(N-1):
  if S[i] == S[i+1] == '#':
    NG = i+1
    break
if C<D<NG:
  print("Yes")
  sys.exit()
for i in range(N-2):
  if S[i] == S[i+1] == S[i+2] == '.':
    OO = i+2
    break
if B<=OO<=D:
  print("Yes")
  sys.exit()
print("No")

Submission status: Wrong Answer

Solution code:
s = input()
s = list(s.replace("BC", "D"))
pos = 0
str_len = len(s)
count = 0
state = 0
seq_a = 0
seq_d = 0


while pos < str_len:
    if state == 0:
        if s[pos] == "A":
            state = 1
            seq_a = 1
        pos += 1
    elif state == 1:
        if s[pos] == "A":
            state = 1
            seq_a += 1
            pos += 1
        elif s[pos] == "D":
            while pos < str_len and s[pos] == "D":
                seq_d += 1
                pos += 1
            tmp_pos = pos - seq_a
            for i in range(tmp_pos, pos):
                s[i] = "A"
            pos = tmp_pos
            if pos < 0:
                pos = 0
            count += seq_a * seq_d
            state = 0
            seq_a = 0
            seq_d = 0
        else:
            state = 0
            pos += 1

print(count)

Submission status: Wrong Answer

Solution code:
s = input()
pos = 0
cnt = 0
acnt = 0
if len(s) < 3:
    print(0)
else:
    while(True):
        if s[pos:pos+3] == "ABC":
            s = s[:pos-acnt] + "BCA"+ s[pos-acnt:pos] + s[pos+3:]
            pos += 2
            cnt += acnt+1
            # print(s, cnt)
        else:
            if s[pos] == "A":
                acnt += 1
            else:
                acnt = 0
            pos += 1
        if pos >= len(s)-2:
            break
    print(cnt)

Submission status: Wrong Answer

Solution code:
s = input()
pos = 0
cnt = 0
if len(s) < 3:
    print(0)
else:
    # print(type(s))
    # print(type(s[0:3]))
    # print(type("ABC"))
    while(True):
        if s[pos:pos+3] == "ABC":
            s = s[:pos] + "BCA" + s[pos+3:]
            pos = 0
            cnt += 1
            # print(s)
        else:
            pos += 1
        if pos >= len(s)-2:
            break
    print(cnt)

Submission status: Wrong Answer

Solution code:
w=list(input())
now=0
num=len(w)
w.append(" ")
count=0
while now<num:
  if w[now]!="A":
    now+=1
  else:
    if w[now+1]!="B":
      now+=1
    else:
      if w[now+2]!="C":
        now+=1
      else:
        w[now]="B"
        w[now+1]="C"
        w[now+2]="A"
        count+=1
        back=now-1
        b=True
        while back>0 and b==True:
          if w[back]!="A":
            b=False
          else:
            w[back]="B"
            w[back+1]="C"
            w[back+2]="A"
            count+=1
            back-=1
        now+=1
print(count)

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = str(input())
if c < d:
    print("Yes")
    exit()
else:
    s = s[b:d+1]
    #print(s)
    for i in range(1,len(s)-1):
        #print("".join(s[i-1]+s[i]+s[i*1]))
        if s[i-1] == "." and s[i] == "." and s[i+1] == ".":
            print("Yes")
            exit()
    print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = str(input())
if c < d:
    print("Yes")
    exit()
else:
    s = s[b:d]
    #print(s)
    for i in range(1,len(s)-1):
        #print("".join(s[i-1]+s[i]+s[i*1]))
        if s[i-1] == "." and s[i] == "." and s[i+1] == ".":
            print("Yes")
            exit()
    print("No")

Submission status: Wrong Answer

Solution code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, a, b, c, d = list(map(int, readline().split()))
    s = str(readline().rstrip().decode('utf-8'))
    if c == d:
        print("No")
    elif c < d:
        print("Yes" if s[a-1:d+1].count("##") == 0 else "No")
    elif c > d:
        print("Yes" if s[a-1:c+1].count("##") == 0 and s[b-1:d+1].count("...") != 0 else "No")


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, a, b, c, d = list(map(int, readline().split()))

    s = str(readline().rstrip().decode('utf-8'))
    if c == d:
        print("No")
    elif c < d:
        wrc = 0
        brc = 0
        wc = 0
        bc = 0
        for i in range(a - 1, max(c, d)):
            if s[i] == "#":
                bc += 1
                wc = 0
            else:
                bc = 0
                wc += 1
            wrc = max(wrc, wc)
            brc = max(brc, bc)
        if brc < 2:
            print("Yes")
        else:
            print("No")
    elif c > d:
        wrc = 0
        brc = 0
        wc = 0
        bc = 0
        for i in range(b - 1, max(c, d)):
            if s[i] == "#":
                bc += 1
                wc = 0
            else:
                bc = 0
                wc += 1
            wrc = max(wrc, wc)
            brc = max(brc, bc)
        if brc < 2 and wrc >= 3:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, a, b, c, d = list(map(int, readline().split()))
    if c == d:
        print("No")
    else:
        s = str(readline().rstrip().decode('utf-8'))
        wrc = 0
        brc = 0
        wc = 0
        bc = 0
        for i in range(a-1, max(c, d)):
            if s[i] == "#":
                bc += 1
                wc = 0
            else:
                bc = 0
                wc += 1
            wrc = max(wrc, wc)
            brc = max(brc, bc)
        if c < d:
            if brc < 2:
                print("Yes")
            else:
                print("No")
        else:
            if brc < 2 and wrc >= 3:
                print("Yes")
            else:
                print("No")


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, a, b, c, d = list(map(int, readline().split()))
    if c == d:
        print("No")
    else:
        s = str(readline().rstrip().decode('utf-8'))
        wrc = 0
        brc = 0
        wc = 0
        bc = 0
        for i in range(n):
            if s[i] == "#":
                bc += 1
                wc = 0
            else:
                bc = 0
                wc += 1
            wrc = max(wrc, wc)
            brc = max(brc, bc)
        if c < d:
            if brc < 2:
                print("Yes")
            else:
                print("No")
        else:
            if brc < 2 and wrc >= 3:
                print("Yes")
            else:
                print("No")


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, a, b, c, d = list(map(int, readline().split()))
    if c == d:
        print("No")
    else:
        s = str(readline().rstrip().decode('utf-8'))
        wrc = 0
        brc = 0
        wc = 0
        bc = 0
        for i in range(n):
            if s[i] == "#":
                bc += 1
                wc = 0
            else:
                bc = 0
                wc += 1
            wrc = max(wrc, wc)
            brc = max(brc, bc)
        if c < d:
            if brc < 2:
                print("Yes")
            else:
                print("No")
        else:
            if brc >= 2 and wrc >= 3:
                print("Yes")
            else:
                print("No")


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, a, b, c, d = list(map(int, readline().split()))
    s = str(readline().rstrip().decode('utf-8'))
    wrc = 0
    brc = 0
    wc = 0
    bc = 0
    for i in range(n):
        if s[i] == "#":
            bc += 1
            wc = 0
        else:
            bc = 0
            wc += 1
        wrc = max(wrc, wc)
        brc = max(brc, bc)
    if c < d:
        if brc < 2:
            print("Yes")
        else:
            print("No")
    else:
        if brc < 2 and wrc >= 3:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,A,B,C,D=map(lambda x: int(x)-1,input().split())
    N+=1
    S=list(input())
    S.append('#')
    if C>D:
        f=False
    else:
        f=True
    for i in range(A,C-1):
        if S[i]=='#' and S[i+1]=='#':
            print('No')
            exit()
        if i>=B-1 and S[i]=='.' and S[i+1]=='.' and S[i+2]=='.':
            f=True
    for i in range(B,D-1):
        if S[i]=='#' and S[i+1]=='#':
            print('No')
            exit()
    print('Yes' if f==True else 'No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,A,B,C,D=map(lambda x: int(x)-1,input().split())
    N+=1
    S=list(input())
    S.append('#')
    if C>D:
        f=False
    else:
        f=True
    for i in range(A,C):
        if S[i]=='#' and S[i+1]=='#':
            print('No')
            exit()
        if i>=B-1 and S[i]=='.' and S[i+1]=='.' and S[i+2]=='.':
            f=True
    for i in range(B,D):
        if S[i]=='#' and S[i+1]=='#':
            print('No')
            exit()
    print('Yes' if f==True else 'No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,A,B,C,D=map(lambda x: int(x)-1,input().split())
    N+=1
    S=list(input())
    S.append('#')
    if C>D:
        f=False
    else:
        f=True
    for i in range(A,B):
        if S[i]=='#' and S[i+1]=='#':
            print('No')
            exit()
        if S[i]=='.' and S[i+1]=='.' and S[i+2]=='.':
            f=True
    for i in range(C,D):
        if S[i]=='#' and S[i+1]=='#':
            print('No')
            exit()
    print('Yes' if f==True else 'No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,A,B,C,D=map(lambda x: int(x)-1,input().split())
    N+=1
    S=list(input())
    S.append('#')
    if (A>B and C<D) or (A<B and C>D):
        f=False
    else:
        f=True
    for x,y in zip([A,B],[C,D]):
        for i in range(x,y):
            if S[i]=='#' and S[i+1]=='#':
                print('No')
                exit()
            if S[i]=='.' and S[i+1]=='.' and S[i+2]=='.':
                f=True
    print('Yes' if f==True else 'No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,A,B,C,D=map(lambda x: int(x)-1,input().split())
    N+=1
    S=list(input())
    S.append('#')
    if (A>B and C<D) or (A<B and C>D):
        f=False
    else:
        f=True
    for x,y in zip([A,B],[C,D]):
        for i in range(x,y-1):
            if S[i]=='#' and S[i+1]=='#':
                print('No')
                exit()
            if S[i]=='.' and S[i+1]=='.' and S[i+2]=='.':
                f=True
    print('Yes' if f==True else 'No')

if __name__ == '__main__':
    main()

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
def test(i,m):
    while i<N :
        if i==m:
            return(1)
        if i+1<N and S[i+1]==".":
            i+=1
        elif i+2<N and S[i+2]==".":
            i+=2
        else:
            return(0)
    return(0)


if C<D:

    if test(A,C) and test(B,D):
        print("Yes")
    else:
        print("No")
else:
    T=B-1
    if "..." in S[T:D+1] and test(A,C) and test(B,D):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
res=list(input())
if c<d:
    for i in range(1,d+1):
        if res[i-1]=="#" and res[i]=="#":
            print("No")
            exit()
    print("Yes")
    exit()

for i in range(b,d+1):
    if i==1:
        continue
    if res[i-2]=="." and res[i-1]=="." and res[i]==".":
        print("Yes")
        exit()
    if res[i-1]=="#" and res[i]=="#":
        print("No")
        exit()
        
print("No")
exit()

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
res=list(input())
if c<d:
    for i in range(1,d):
        if res[i-1]=="#" and res[i]=="#":
            print("No")
            exit()
    print("Yes")
    exit()

for i in range(b,d+1):
    if i==1:
        continue
    if res[i-2]=="." and res[i-1]=="." and res[i]==".":
        print("Yes")
        exit()
    if res[i-1]=="#" and res[i]=="#":
        print("No")
        exit()
        
print("No")
exit()

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
res=list(input())
if c<d:
    for i in range(1,n):
        if res[i-1]=="#" and res[i]=="#":
            print("No")
            exit()
    print("Yes")
    exit()

for i in range(b,d+1):
    if i==1:
        continue
    if res[i-2]=="." and res[i-1]=="." and res[i]==".":
        print("Yes")
        exit()
    if res[i-1]=="#" and res[i]=="#":
        print("No")
        exit()
print("No")
exit()

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
res=list(input())
if c<d:
    for i in range(1,n):
        if res[i-1]=="#" and res[i]=="#":
            print("No")
            exit()
    print("Yes")
    exit()

for i in range(b,d+1):
    # if i==1:
    #     continue
    if res[i-2]=="." and res[i-1]=="." and res[i]==".":
        print("Yes")
        exit()
print("No")
exit()

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
res=list(input())
if c<d:
    for i in range(1,n):
        if res[i-1]=="#" and res[i]=="#":
            print("No")
            exit()
    print("Yes")
    exit()


for i in range(b,d+1):
    if i==1 or i<=b+1:
        continue
    if res[i-2]=="." and res[i-1]=="." and res[i]==".":
        print("Yes")
        exit()
print("No")
exit()

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
res=list(input())
if c<d:
    for i in range(1,n):
        if res[i-1]=="#" and res[i]=="#":
            print("No")
            exit()
    print("Yes")
    exit()

for i in range(b,d+1):
    if i==1:
        continue
    if res[i-2]=="." and res[i-1]=="." and res[i]==".":
        print("Yes")
        exit()
print("No")
exit()

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
res=list(input())
if c<d:
    for i in range(1,n):
        if res[i-1]=="#" and res[i]=="#":
            print("No")
            exit()
    print("Yes")
    exit()

for i in range(b,d):
    if i==1:
        continue
    if res[i-2]=="." and res[i-1]=="." and res[i]==".":
        print("Yes")
        exit()
print("No")
exit()

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
x=[]
cnt=1
y=s[0]
for i in range(1,n):
    if s[i]==y:
        cnt+=1
    else:
        x.append([cnt,y])
        cnt=1
        y=s[i]
x.append([cnt,y])
for i in x:
    if i[0]>=2 and i[1]=='#':
        print("No")
        exit()
if a<b and c<d:
    print("Yes")
    exit()
ans=0
for i in range(b-1,d+2):
    if s[i]==".":
        ans+=1
    else:
        if ans>=3:
            print("Yes")
            exit()
        ans=0
if ans>=3:
    print("Yes")
    exit()
"""
if s[b+1]=="." and s[b-1]==".":
    print("Yes")
    exit()
if s[d-1]=="." and s[d+1]==".":
    print("Yes")
    exit()
"""
print("No")

Submission status: Wrong Answer

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

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
x=[]
cnt=1
y=s[0]
for i in range(1,n):
    if s[i]==y:
        cnt+=1
    else:
        x.append([cnt,y])
        cnt=1
        y=s[i]
x.append([cnt,y])
for i in x:
    if i[0]>=2 and i[1]=='#':
        print("No")
        exit()
if a<b and c<d:
    print("Yes")
    exit()
ans=0
for i in range(b,d+1):
    if s[i]==".":
        ans+=1
    else:
        if ans>=3:
            print("Yes")
            exit()
        ans=0
if ans>=3:
    print("Yes")
    exit()
if s[b+1]=="." and s[b-1]==".":
    print("Yes")
    exit()
if s[d-1]=="." and s[d+1]==".":
    print("Yes")
    exit()
print("No")

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
x=[]
cnt=1
y=s[0]
g=[0,0,0,0]
for i in range(1,n):
    if s[i]==y:
        cnt+=1
    else:
        x.append([cnt,y])
        cnt=1
        y=s[i]
    if i==a:
        g[0]=len(x)
    if i==b:
        g[1]=len(x)
    if i==c:
        g[2]=len(x)
    if i==d:
        g[3]=len(x)
x.append([cnt,y])
for i in x:
    if i[0]>=2 and i[1]=='#':
        print("No")
        exit()
if a<b and c<d:
    print("Yes")
    exit()
ans=0
for i in range(b,d+1):
    if s[i]==".":
        ans+=1
    else:
        if ans>=3:
            print("Yes")
            exit()
        ans=0
if s[b+1]=="." and s[b-1]==".":
    print("Yes")
    exit()
if s[d-1]=="." and s[d+1]==".":
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=list(input())
a-=1
b-=1
c-=1
d-=1
ans=0
for i in range(1,n):
    if s[i-1]+s[i]=='##':
        ans=1
if ans==1:
    print('No')
elif d>c:
    print('Yes')
else:
    for i in range(b+1,n):
        if s[i-2]+s[i-1]+s[i]=='...':
            ans=2
    if s[d-1]+s[d]+s[d+1]=='...':
        ans+=1
    if ans==3:
        print('Yes')
    else:
        print('No')

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
x=[]
cnt=1
y=s[0]
g=[0,0,0,0]
for i in range(1,n):
    if s[i]==y:
        cnt+=1
    else:
        x.append([cnt,y])
        cnt=1
        y=s[i]
    if i==a:
        g[0]=len(x)
    if i==b:
        g[1]=len(x)
    if i==c:
        g[2]=len(x)
    if i==d:
        g[3]=len(x)
x.append([cnt,y])
for i in x:
    if i[0]>=2 and i[1]=='#':
        print("No")
        exit()
if a<b and c<d:
    print("Yes")
    exit()
ans=0
for i in range(b,d+1):
    if s[i]==".":
        ans+=1
    else:
        if ans>=3:
            print("Yes")
            exit()
        ans=0
if s[b+1]=="." and s[b-1]==".":
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=list(input())
a-=1
b-=1
c-=1
d-=1
ans=0
for i in range(1,n):
    if s[i-1]+s[i]=='##':
        ans=1
if ans==1:
    print('No')
elif d>c:
    print('Yes')
else:
    for i in range(b,n):
        if s[i-2]+s[i-1]+s[i]=='...':
            ans=2
    if ans==2:
        print('Yes')
    else:
        print('No')

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
x=[]
cnt=1
y=s[0]
g=[0,0,0,0]
for i in range(1,n):
    if s[i]==y:
        cnt+=1
    else:
        x.append([cnt,y])
        cnt=1
        y=s[i]
    if i==a:
        g[0]=len(x)
    if i==b:
        g[1]=len(x)
    if i==c:
        g[2]=len(x)
    if i==d:
        g[3]=len(x)
x.append([cnt,y])
for i in x:
    if i[0]>=2 and i[1]=='#':
        print("No")
        exit()
if a<b and c<d:
    print("Yes")
    exit()
ans=0
for i in range(b,d+1):
    if s[i]==".":
        ans+=1
    else:
        if ans>=3:
            print("Yes")
            exit()
        ans=0

if b>1 and s[b-1]=="." and s[b-2]==".":
    print("Yes")
    exit()
if s[b+1]=="." and s[b-1]==".":
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=list(input())
a-=1
b-=1
c-=1
d-=1
ans=0
for i in range(1,n):
    if s[i-1]+s[i]=='##':
        ans=1
if ans==1:
    print('No')
elif d>c:
    print('Yes')
else:
    for i in range(b+1,n):
        if s[i-2]+s[i-1]+s[i]=='...':
            ans=2
    if ans==2:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=list(input())
a-=1
b-=1
c-=1
d-=1
ans=0
for i in range(1,n):
    if s[i-1]+s[i]=='##':
        ans=1
if ans==1:
    print('No')
elif d>c:
    print('Yes')
else:
    for i in range(b+2,n):
        if s[i-2]+s[i-1]+s[i]=='...':
            ans=2
    if ans==2:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=list(input())
a-=1
b-=1
c-=1
d-=1
ans=0
for i in range(1,n):
    if s[i-1]+s[i]=='##':
        ans=1
if ans==1:
    print('No')
elif d>c:
    print('Yes')
else:
    for i in range(b+3,n):
        if s[i-2]+s[i-1]+s[i]=='...':
            ans=2
    if ans==2:
        print('Yes')
    else:
        print('No')

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
x=[]
cnt=1
y=s[0]
g=[0,0,0,0]
for i in range(1,n):
    if s[i]==y:
        cnt+=1
    else:
        x.append([cnt,y])
        cnt=1
        y=s[i]
    if i==a:
        g[0]=len(x)
    if i==b:
        g[1]=len(x)
    if i==c:
        g[2]=len(x)
    if i==d:
        g[3]=len(x)
x.append([cnt,y])
for i in x:
    if i[0]>=2 and i[1]=='#':
        print("No")
        exit()
if a<b and c<d:
    print("Yes")
    exit()
ans=0
for i in range(b,d):
    if s[i]==".":
        ans+=1
    else:
        if ans>=3:
            print("Yes")
            exit()
        ans=0
print("No")

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
x=[]
cnt=1
y=s[0]
g=[0,0,0,0]
for i in range(1,n):
    if s[i]==y:
        cnt+=1
    else:
        x.append([cnt,y])
        cnt=1
        y=s[i]
    if i==a:
        g[0]=len(x)
    if i==b:
        g[1]=len(x)
    if i==c:
        g[2]=len(x)
    if i==d:
        g[3]=len(x)
x.append([cnt,y])
for i in x:
    if i[0]>=2 and i[1]=='#':
        print("No")
        exit()
if a<b and c<d:
    print("Yes")
    exit()
for i in range(g[1],g[2]-1):
    if x[i][1]=="." and x[i][0]>=3:
        print("Yes")
        exit()
print("No")

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
x=[]
cnt=1
y=s[0]
g=[0,0,0,0]
for i in range(1,n):
    if s[i]==y:
        cnt+=1
    else:
        x.append([cnt,y])
        cnt=1
        y=s[i]
    if i==a:
        g[0]=len(x)
    if i==b:
        g[1]=len(x)
    if i==c:
        g[2]=len(x)
    if i==d:
        g[3]=len(x)
x.append([cnt,y])
for i in x:
    if i[0]>=2 and i[1]=='#':
        print("No")
        exit()
if a<b and c<d:
    print("Yes")
    exit()
for i in range(g[1],min(g[2]+1,len(x))):
    if x[i][1]=="." and x[i][0]>=3:
        print("Yes")
        exit()
print("No")

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
x=[]
cnt=1
y=s[0]
g=[0,0,0,0]
for i in range(1,n):
    if s[i]==y:
        cnt+=1
    else:
        x.append([cnt,y])
        cnt=1
        y=s[i]
    if i==a:
        g[0]=len(x)
    if i==b:
        g[1]=len(x)
    if i==c:
        g[2]=len(x)
    if i==d:
        g[3]=len(x)
x.append([cnt,y])
for i in x:
    if i[0]>=2 and i[1]=='#':
        print("No")
        exit()
if a<b and c<d:
    print("Yes")
    exit()
for i in range(g[1],g[2]):
    if x[i][1]=="." and x[i][0]>=3:
        print("Yes")
        exit()
print("No")
#print(x)
#print(g)

Submission status: Wrong Answer

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

ans=True
if "##" in S[A:C+1]:
  ans=False
if "##" in S[B:D+1]:
  ans=False
  
if (A-B)*(C-D)<0:
  commonL=max(A,B)
  commonR=min(C,D)
  if commonR<commonL:
    ans=False
  elif "..." not in S[commonL:commonR+1]:
    ans=False

print(("No","Yes")[ans])