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(int,input().split())
s=input()

if "##" in s:print("No")
elif c>d and "..." not in s[b-2:d]:print("No")
else:print("Yes")

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 and "..." not in s[b:d]:print("No")
else:print("Yes")

Submission status: Wrong Answer

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

flag=0
for i in range(n-1):
    if S[i]==S[i+1]=="#":
        flag=1;break

if flag:print("No");exit()

if c<d:print("Yes")
else:
    for i in s[b:d+1].split("#"):
        if len(i)>=3:print("Yes");exit()
    print("No")

Submission status: Wrong Answer

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

flag=0
for i in range(n-1):
    if S[i]==S[i+1]=="#":
        flag=1;break

if flag:print("No");exit()

if c<d:print("Yes")
else:
    if s[b+1]=="." and (b-1!=a or s[b-1]!="#"):print("Yes");exit()
    for i in s[b:d].split("#"):
        if len(i)>=3:print("Yes");exit()
    print("No")

Submission status: Wrong Answer

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

flag=0
for i in range(n-1):
    if S[i]==S[i+1]=="#":
        flag=1;break

if flag:print("No");exit()

if c<d:print("Yes")
else:
    if s[b+1]==".":print("Yes");exit()
    for i in s[b:d].split("#"):
        if len(i)>=3:print("Yes");exit()
    print("No")

Submission status: Wrong Answer

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

flag=0
for i in range(n-1):
    if S[i]==S[i+1]=="#":
        flag=1;break

if flag:print("No");exit()

if c<d:print("Yes")
else:
    for i in s[b-1:d].split("#"):
        if len(i)>=3:print("Yes");exit()
    if s[b-1]==s[b+1]==".":print("Yes");exit()
    print("No")

Submission status: Wrong Answer

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

flag=0
for i in range(n-1):
    if S[i]==S[i+1]=="#":
        flag=1;break

if flag:print("No");exit()

if c<d:print("Yes")
else:
    for i in s[b-1:d].split("#"):
        if len(i)>=3:print("Yes");exit()
    print("No")

Submission status: Wrong Answer

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

flag=0
for i in range(n-1):
    if S[i]==S[i+1]=="#":
        flag=1;break

if flag:print("No");exit()

if c<d:print("Yes")
else:
    for i in s[b:d].split("#"):
        if len(i)>=3:print("Yes");exit()
    print("No")

Submission status: Wrong Answer

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

flag=0
for i in range(n-1):
    if S[i]==S[i+1]=="#":
        flag=1;break

if flag:print("No");exit()

if c<d:print("Yes")
else:
    for i in s.split("#"):
        if len(i)>=3:print("Yes");exit()
    print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,a,b,c,d = inpl()
s = input()
def chk(i):
    if s[i] == s[i+1] == '#':
        print('No')
        quit()
    return True
def cc(i):
    if s[i] == s[i+1] == s[i+2] == '.':
        return True
    return False

if c < d:
    for i in range(b-1,d-1):
        chk(i)
    for i in range(a-1,c-1):
        chk(i)
else:
    for i in range(b-1,d-2):
        if cc(i):
            break
    else:
        print('No')
        quit()
    for i in range(a-1,c-1):
        chk(i)
print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,a,b,c,d = inpl()
s = input()
def chk(i,a,d):
    if i < a-1 or i > d-2:
        return True
    if s[i] == s[i+1] == '#':
        print('No')
        quit()
    return True

if b < c < d:
    for i in range(n-1):
        chk(i,a,d)
elif c < b < d:
    for i in range(n-1):
        chk(i,a,c)
        chk(i,b,d)
else:
    flag = False
    for i in range(n-1):
        chk(i,a,c)
        if i == n-2 or i < b-1 or i > d-3:
            continue
        if s[i] == s[i+1] == s[i+2] == '.':
            flag = True
    if not flag:
        print('No')
        quit()
print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,a,b,c,d = inpl()
s = input()
def chk(i):
    if i < a-1 or i > d-2:
        return True
    if s[i] == s[i+1] == '#':
        print('No')
        quit()
    return True

if c < d:
    for i in range(n-1):
        chk(i)
else:
    flag = False
    for i in range(n-1):
        chk(i)
        if i == n-2 or i < b-1 or i > d-3:
            continue
        if s[i] == s[i+1] == s[i+2] == '.':
            flag = True
    if not flag:
        print('No')
        quit()
print('Yes')

Submission status: Wrong Answer

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

if c < d:
    for i in range(b-1, d-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            exit()

    t = ''
    for i in range(len(s)):
        if i == d-1:
            t += '#'
        else:
            t += s[i]

    for i in range(a-1, c-1):
        if t[i] == '#' and t[i+1] == '#':
            print('No')
            exit()

    print('Yes')
elif c > d:
    for i in range(a-1, c-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            exit()

    for bi in range(b-1,d):
        if s[bi-1] == s[bi] == s[bi+1] == '.':
            print('Yes')
            exit()

else:
    print('No')

Submission status: Wrong Answer

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

if c < d:
    for i in range(b-1, d-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            exit()

    t = ''
    for i in range(len(s)):
        if i == d-1:
            t += '#'
        else:
            t += s[i]

    for i in range(a-1, c-1):
        if t[i] == '#' and t[i+1] == '#':
            print('No')
            exit()

    print('Yes')
elif c > d:
    for i in range(a-1, c-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            exit()

    flag = False
    for i in range(b-1, d-2):
        if s[i:i+3] == '...':
            flag = True
    if not flag:
        print('No')
        exit()

    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:
    for i in range(b-1, d-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            exit()

    t = ''
    for i in range(len(s)):
        if i == d-1:
            t += '#'
        else:
            t += s[i]

    for i in range(a-1, c-1):
        if t[i] == '#' and t[i+1] == '#':
            print('No')
            exit()

    print('Yes')
elif c > d:
    for i in range(a-1, c-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            exit()

    flag = False
    for i in range(b-1, d-3):
        if s[i:i+3] == '...':
            flag = True
    if not flag:
        print('No')
        exit()

    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:
    for i in range(b-1, n-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            exit()

    t = ''
    for i in range(len(s)):
        if i == d-1:
            t += '#'
        else:
            t += s[i]

    for i in range(a-1, n-1):
        if t[i] == '#' and t[i+1] == '#':
            print('No')
            exit()

    print('Yes')
elif c > d:
    for i in range(a-1, n-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            exit()

    flag = False
    for i in range(b-1, d-3):
        if s[i:i+3] == '...':
            flag = True
    if not flag:
        print('No')
        exit()
        
    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:
    for i in range(b-1, n-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            exit()

    t = ''
    for i in range(len(s)):
        if i == d-1:
            t += '#'
        else:
            t += s[i]

    for i in range(a-1, n-1):
        if t[i] == '#' and t[i+1] == '#':
            print('No')
            exit()

    print('Yes')
elif c > d:
    for i in range(a-1, n-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            exit()

    flag = False
    for i in range(b-1, d-3):
        if s[i:i+3] == '...':
            flag = True
    if not flag:
        print('No')
        exit()

    t = ''
    for i in range(len(s)):
        if i == c-1:
            t += '#'
        else:
            t += s[i]

    for i in range(b-1, n-1):
        if t[i] == '#' and t[i+1] == '#':
            print('No')
            exit()

    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:
    for i in range(b-1, n-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            exit()

    t = ''
    for i in range(len(s)):
        if i == d-1:
            t += '#'
        else:
            t += s[i]

    for i in range(a-1, n-1):
        if t[i] == '#' and t[i+1] == '#':
            print('No')
            exit()

    print('Yes')
elif c > d:
    for i in range(a-1, n-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            exit()

    t = ''
    for i in range(len(s)):
        if i == c-1:
            t += '#'
        else:
            t += s[i]

    for i in range(b-1, n-1):
        if t[i] == '#' and t[i+1] == '#':
            print('No')
            exit()

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

Submission status: Wrong Answer

Solution code:
from sys import stdin

n,a,b,c,d = [int(x) for x in stdin.readline().rstrip().split()]
s = ["."]+list(stdin.readline().rstrip())
for i in range(b,d):
    if s[i] == "#" and s[i+1] == "#":
        print("No")
        exit()
for j in range(a,c):
    if s[j] == "#" and s[j+1] == "#":
        print("No")
        exit()
if c < d:
    print("Yes")
    exit()
for k in range(b,d):
    if s[k-1] == "." and s[k] == "." and s[k+1] == ".":
        print("Yes")
        exit()
print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin

n,a,b,c,d = [int(x) for x in stdin.readline().rstrip().split()]
s = ["#"]+list(stdin.readline().rstrip())
for i in range(b,d):
    if s[i] == "#" and s[i+1] == "#":
        print("No")
        exit()
for j in range(a,c):
    if s[j] == "#" and s[j+1] == "#":
        print("No")
        exit()
if c < d:
    print("Yes")
    exit()
for k in range(b,d):
    if s[k-1] == "." and s[k] == "." and s[k+1] == ".":
        print("Yes")
        exit()
print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin

n,a,b,c,d = [int(x) for x in stdin.readline().rstrip().split()]
s = ["#"]+list(stdin.readline().rstrip())
flag = 0
if c<d:
    for i in range(b,d-1):
        if s[i] == "#" and s[i+1] == "#":
            print("No")
            exit()
    for j in range(a,c-1):
        if s[j] == "#" and s[j+1] == "#":
            print("No")
            exit()
    print("Yes")
else:
    for i in range(b,d-1):
        if s[i] == "#" and s[i+1] == "#":
            print("No")
            exit
        if s[i-1] == "." and s[i] == "." and s[i+1] == ".":
            flag = 1
    for j in range(a,c-1):
        if s[j] == "#" and s[j+1] == "#":
            print("No")
            exit()
    if flag == 1:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin

n,a,b,c,d = [int(x) for x in stdin.readline().rstrip().split()]
s = ["#"]+list(stdin.readline().rstrip())
flag = 0
if c<d:
    for i in range(b,d):
        if s[i] == "#" and s[i+1] == "#":
            print("No")
            exit()
    for j in range(a,c):
        if s[j] == "#" and s[j+1] == "#":
            print("No")
            exit()
    print("Yes")
else:
    for i in range(b,d):
        if s[i] == "#" and s[i+1] == "#":
            print("No")
            exit
        if s[i-1] == "." and s[i] == "." and s[i+1] == ".":
            flag = 1
    for j in range(a,c):
        if s[j] == "#" and s[j+1] == "#":
            print("No")
            exit()
    if flag == 1:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin

n,a,b,c,d = [int(x) for x in stdin.readline().rstrip().split()]
s = ["#"]+list(stdin.readline().rstrip())
flag = 0
if c<d:
    for i in range(b,d):
        if s[i] == "#" and s[i+1] == "#":
            print("No")
            exit()
    for j in range(a,c):
        if s[j] == "#" and s[j+1] == "#":
            print("No")
            exit()
    print("Yes")
else:
    for i in range(b,d):
        if s[i] == "#" and s[i+1] == "#":
            print("No")
            exit
        elif s[i-1] == "." and s[i+1] == "." and s[i] == ".":
            flag = 1
    if flag == 0:
        print("No")
        exit()
    for j in range(a,c):
        if s[j] == "#" and s[j+1] == "#":
            print("No")
            exit()
    print("Yes")

Submission status: Wrong Answer

Solution code:
from sys import stdin

n,a,b,c,d = [int(x) for x in stdin.readline().rstrip().split()]
s = ["#"]+list(stdin.readline().rstrip())
flag = 0
if c<d:
    for i in range(b,d):
        if s[i] == "#" and s[i+1] == "#":
            print("No")
            exit()
    s[d] = "#"
    for j in range(a,c):
        if s[j] == "#" and s[j+1] == "#":
            print("No")
            exit()
    print("Yes")
else:
    for i in range(b,d):
        if s[i] == "#" and s[i+1] == "#":
            print("No")
            exit
        if s[i-1] == "." and s[i+1] == "." and s[i] != "#":
            s[i] = "#"
            b = i
            flag = 1
            break
    if flag == 0:
        print("No")
        exit()
    for j in range(a,c):
        if s[j] == "#" and s[j+1] == "#":
            print("No")
            exit()
    for k in range(b,d):
        if s[k] == "#" and s[k+1] == "#":
            print("No")
            exit()
    print("Yes")

Submission status: Wrong Answer

Solution code:
from sys import stdin

n,a,b,c,d = [int(x) for x in stdin.readline().rstrip().split()]
s = ["#"]+list(stdin.readline().rstrip())
for i in range(b,d-1):
    if s[i] == "#" and s[i+1] == "#":
        print("No")
        exit()
s[d] = "#"
for j in range(a,c-1):
    if s[j] == "#" and s[i+1] == "#":
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
N,Sa,Sb,Ga,Gb = map(int, input().split())
S = input()

Sa-=1
Sb-=1
Ga-=1
Gb-=1

for i in range(Sa,Ga):
    if S[i] == "#" and S[i+1] == "#":
        print("No")
        exit()
for i in range(Sb,Gb):
    if S[i] == "#" and S[i+1] == "#":
        print("No")
        exit()

if Gb < Ga: #Need to swap

    for i in range(Sb-1,Gb-1):
        if S[i] == "." and S[i+1] == "." and S[i+2] == "." :
            print("Yes")
            exit()

    print("No")

else: # No need to swap
    print("Yes")

Submission status: Wrong Answer

Solution code:
N,Sa,Sb,Ga,Gb = map(int, input().split())
S = input()

Sa-=1
Sb-=1
Ga-=1
Gb-=1

for i in range(Sa,Ga):
    if S[i] == "#" and S[i+1] == "#":
        print("No")
        exit()
for i in range(Sb,Gb):
    if S[i] == "#" and S[i+1] == "#":
        print("No")
        exit()

if Gb < Ga: #Need to swap

    for i in range(Sb,Gb-2):
        if S[i] == "." and S[i+1] == "." and S[i+2] == "." :
            print("Yes")
            exit()

    print("No")

else: # No need to swap
    print("Yes")

Submission status: Wrong Answer

Solution code:
N,Sa,Sb,Ga,Gb = map(int, input().split())
S = input()

Sa-=1
Sb-=1
Ga-=1
Gb-=1

if Gb < Ga: #Need to swap
    for i in range(Sa,Ga):
        if S[i] == "#" and S[i+1] == "#":
            print("No")
            exit()

    j=Sa
    for j in range(Sa,-1,-1):
        if S[j] == "#" and S[j-1] == "#":
            break
        if S[j] == "." and S[j-1] == "." and S[j-2] == "." :
            print("Yes")
            exit()

    for i in range(j,len(S)-2):
        if S[i] == "#" and S[i+1] == "#":
            break
        if S[i] == "." and S[i+1] == "." and S[i+2] == "." :
            print("Yes")
            exit()
    print("No")

else: # No need to swap
    for i in range(Sa,Ga):
        if S[i] == "#" and S[i+1] == "#":
            print("No")
            exit()
    for i in range(Sb,Gb):
        if S[i] == "#" and S[i+1] == "#":
            print("No")
            exit()
    print("Yes")

Submission status: Wrong Answer

Solution code:
N,Sa,Sb,Ga,Gb = map(int, input().split())
S = input()

Sa-=1
Sb-=1
Ga-=1
Gb-=1

if Gb < Ga: #Need to swap
    for i in range(Sa,Ga):
        if S[i] == "#" and S[i+1] == "#":
            print("No")
            exit()

    j=Sa
    for j in range(Sa,0,-1):
        if S[j] == "#" and S[j-1] == "#":
            break
        if S[j] == "." and S[j-1] == "." and S[j-2] == "." :
            print("Yes")
            exit()

    first_i=j

    for i in range(first_i,len(S)-2):
        if S[i] == "#" and S[i+1] == "#":
            break
        if S[i] == "." and S[i+1] == "." and S[i+2] == "." :
            print("Yes")
            exit()
    print("No")

else: # No need to swap
    for i in range(Sa,Ga):
        if S[i] == "#" and S[i+1] == "#":
            print("No")
            exit()
    for i in range(Sb,Gb):
        if S[i] == "#" and S[i+1] == "#":
            print("No")
            exit()
    print("Yes")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
X = max(C,D)
rock = 0
check = 0
for i in S[A:X]:
    if i == '#':
        rock += 1
    else:
        rock = 0
    if rock == 2:
        check = 1
        break
if check == 0 and C > D:
    plane = 0
    pcheck = 0
    for i in S[B-2:D]:
        if i == '.':
            plane += 1
            if plane == 3:
                pcheck = 1
                break
        else:
            plane = 0
    if pcheck == 0:
        check = 0
if check == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
X = max(C,D)
rock = 0
check = 0
for i in S[A:X]:
    if i == '#':
        rock += 1
    else:
        rock = 0
    if rock == 2:
        check = 0
        break
if check == 0 and C > D:
    plane = 0
    pcheck = 0
    for i in S[B-2:D]:
        if i == '.':
            plane += 1
            if plane == 3:
                pcheck = 1
                break
        else:
            plane = 0
    if pcheck == 0:
        check = 1
if check == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
X = max(C,D)
rock = 0
check = 0
for i in S[A:X+10]:
    if i == '#':
        rock += 1
    else:
        rock = 0
    if rock == 2:
        check = 1
        break
if check == 0 and C > D:
    plane = 0
    pcheck = 0
    for i in S[B-2:D]:
        if i == '.':
            plane += 1
            if plane == 3:
                pcheck = 1
                break
        else:
            plane = 0
    if pcheck == 0:
        check = 1
if check == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
X = max(C,D)
rock = 0
check = 0
for i in S[A:X+1]:
    if i == '#':
        rock += 1
    else:
        rock = 0
    if rock == 2:
        check = 1
        break
if check == 0 and C > D:
    plane = 0
    pcheck = 0
    for i in S[B-2:D]:
        if i == '.':
            plane += 1
            if plane == 3:
                pcheck = 1
                break
        else:
            plane = 0
    if pcheck == 0:
        check = 1
if check == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
X = max(C,D)
rock = 0
check = 0
for i in S[A:X]:
    if i == '#':
        rock += 1
    else:
        rock = 0
    if rock == 2:
        check = 1
        break
if check == 0 and C > D:
    plane = 0
    pcheck = 0
    for i in S[B-2:D]:
        if i == '.':
            plane += 1
            if plane == 3:
                pcheck = 1
                break
        else:
            plane = 0
    if pcheck == 0:
        check = 1
if check == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
X = max(C,D)
rock = 0
check = 0
for i in S[A-1:X-1]:
    if i == '#':
        rock += 1
    else:
        rock = 0
    if rock == 2:
        check = 1
if check == 0 and C > D:
    plane = 0
    pcheck = 0
    for i in S[B-2:D]:
        if i == '.':
            plane += 1
            if plane == 3:
                pcheck = 1
                break
        else:
            plane = 0
    if pcheck == 0:
        check = 1
if check == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
X = max(C,D)
rock = 0
check = 0
for i in S[A-1:X-1]:
    if i == '#':
        rock += 1
    else:
        rock = 0
    if rock == 2:
        check = 1
        break
if check == 0 and C > D:
    plane = 0
    pcheck = 0
    for i in S[B-2:D]:
        if i == '.':
            plane += 1
            if plane == 3:
                pcheck = 1
                break
        else:
            plane = 0
    if pcheck == 0:
        check = 1
if check == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
X = max(C,D)
rock = 0
check = 0
for i in S[A-1:X-1]:
    if i == '#':
        rock += 1
    else:
        rock = 0
    if rock == 2:
        check = 1
        break
if check == 0 and C > D:
    plane = 0
    max = 0
    for i in S[B-2:D]:
        if i == '.':
            plane += 1
            if plane > max:
                max = plane
        else:
            plane = 0
    if max < 3:
        check = 1
if check == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
X = max(C,D)
rock = 0
check = 0
for i in S[A-1:X-1]:
    if i == '#':
        rock += 1
    else:
        rock = 0
    if rock == 2:
        check = 1
        break
if C > D:
    plane = 0
    max = 0
    for i in S[B-2:D]:
        if i == '.':
            plane += 1
            if plane > max:
                max = plane
        else:
            plane = 0
    if max < 3:
        check = 1
if check == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

def is_possible(start, goal):
    for i in range(start, goal - 1):
        if s[i] == "#" and s[i + 1] == "#":
            return False
    return True
  
def is_possible2(start, goal):
    for i in range(start, goal):
        if s[i - 1] == "." and s[i] == "." and s[i + 1] == ".":
            return True
    return False

if c < d:
    if is_possible(a - 1, c - 1) and is_possible(b - 1, d - 1):
        print("Yes")
    else:
        print("No")
else:
    if is_possible(a - 1, c - 1) and is_possible(b - 1, d - 1) and is_possible2(b - 1, d - 1):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

def is_possible(start, goal):
    for i in range(start, goal - 1):
        if s[i] == "#" and s[i + 1] == "#":
            return False
    return True
  
def is_possible2(start, goal):
    for i in range(start, goal - 1):
        if s[i - 1] == "." and s[i] == "." and s[i + 1] == ".":
            return True
    return False

if c < d:
    if is_possible(a - 1, c - 1) and is_possible(b - 1, d - 1):
        print("Yes")
    else:
        print("No")
else:
    if is_possible(a - 1, c - 1) and is_possible(b - 1, d - 1) and is_possible2(b - 1, d - 1):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s = input()
def is_a(x, y):
  for i in range(x, y-1):
    if s[i]==s[i+1]=="#":
      return False
  return True
def is_f(x, y):
  for i in range(x+1, y):
    if s[i-1]==s[i]==s[i+1]==".":
      return True
  return False

ans = "No"
if is_a(a, b) and is_a(c, d):
  if c < d or is_f(b, d):
    ans = "Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
# import sys
n, a, b, c, d = map(int, input().split())
s = list(input().replace(".", " "))

a -= 1
b -= 1
c -= 1
d -= 1

end = max(c, d)

for i in range(a, end):
    if s[i] == "#" and s[i+1] == "#":
        print("No")
        exit()
        # sys.exit(0)


if c > d:
    for i in range(b+1, d):
        if s[i-1] == " " and s[i] == " " and s[i+1] == " ":
            print("Yes")
            exit()
            # sys.exit(0)
    print("No")
    exit()
    # sys.exit(0)
else:
    print("Yes")
    exit()
    # sys.exit(0)

Submission status: Wrong Answer

Solution code:
# import sys
n, a, b, c, d = map(int, input().split())
s = list(input().replace(".", " "))

a -= 1
b -= 1
c -= 1
d -= 1

end = max(c, d)

for i in range(a, end):
    if s[i] == "#" and s[i+1] == "#":
        print("No")
        exit()
        # sys.exit(0)


if c > d and s[d-1] == "#":
    for i in range(b+1, d):
        if s[i-1] == " " and s[i] == " " and s[i+1] == " ":
            print("Yes")
            exit()
            # sys.exit(0)
    print("No")
    exit()
    # sys.exit(0)
else:
    print("Yes")
    exit()
    # sys.exit(0)

Submission status: Wrong Answer

Solution code:
# import sys
n, a, b, c, d = map(int, input().split())
s = list(input().replace(".", " "))

a -= 1
b -= 1
c -= 1
d -= 1

end = max(c, d)

for i in range(b, end):
    if s[i] == "#" and s[i+1] == "#":
        print("No")
        exit()
        # sys.exit(0)


if c > d and s[d-1] == "#":
    for i in range(b+1, d-1):
        if s[i-1] == " " and s[i] == " " and s[i+1] == " ":
            print("Yes")
            exit()
            # sys.exit(0)
    print("No")
    exit()
    # sys.exit(0)
else:
    print("Yes")
    exit()
    # sys.exit(0)

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
#0-indexedにするため
A-=1;B-=1;C-=1;D-=1
'''
A→C
B→D
順序としてありえるのは
A<B<D<C
A<B<C<D
A<C<B<D
C<Dなら飛び越える必要がない
C>Dなら飛び越える必要がある
飛び越えを成功させるためには3連続の.が途中にあることが必要十分である
'''
if C<D:
    #ここは飛び越える必要がないとき
    Snuke=[0 for i in range(N)]
    Fnuke=[0 for i in range(N)]
    Snuke[A]=1
    Fnuke[B]=1
    for i in range(1,N):
        if S[i]=="#":
            continue
        if Snuke[i-1]==1:
            Snuke[i]=1
        if i>1 and Snuke[i-2]==1:
            Snuke[i]=1
        if Fnuke[i-1]==1:
            Fnuke[i]=1
        if i>1 and Fnuke[i-2]==1:
            Fnuke[i]=1
    if Snuke[C]==1 and Fnuke[D]==1:
        print("Yes")
    else:
        print("No")
else:
    #A<B<D<C
    #ここは飛び越える必要があるとき
    Snuke=[0 for i in range(N)]
    Fnuke=[0 for i in range(N)]
    Snuke[A]=1
    Fnuke[B]=1
    for i in range(1,N):
        if S[i]=="#":
            continue
        if Snuke[i-1]==1:
            Snuke[i]=1
        if i>1 and Snuke[i-2]==1:
            Snuke[i]=1
        if Fnuke[i-1]==1:
            Fnuke[i]=1
        if i>1 and Fnuke[i-2]==1:
            Fnuke[i]=1
    flag=0
    for i in range(B,D-2):
        if S[i]=="." and S[i+1]=="." and S[i+2]==".":
            flag=1
            break
    if Snuke[C]==1 and Fnuke[D]==1 and flag==1:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
#0-indexedにするため
A-=1;B-=1;C-=1;D-=1
'''
A→C
B→D
順序としてありえるのは
A<B<D<C
A<B<C<D
A<C<B<D
C<Dなら飛び越える必要がない
C>Dなら飛び越える必要がある
飛び越えを成功させるためには3連続の.が途中にあることが必要十分である
'''
if C<D:
    #ここは飛び越える必要がないとき
    Snuke=[0 for i in range(N)]
    Fnuke=[0 for i in range(N)]
    Snuke[A]=1
    Fnuke[B]=1
    for i in range(1,N):
        if S[i]=="#":
            continue
        if Snuke[i-1]==1:
            Snuke[i]=1
        if i>1 and Snuke[i-2]==1:
            Snuke[i]=1
        if Fnuke[i-1]==1:
            Fnuke[i]=1
        if i>1 and Fnuke[i-2]==1:
            Fnuke[i]=1
    if Snuke[C]==1 and Fnuke[D]==1:
        print("Yes")
    else:
        print("No")
else:
    #A<B<D<C
    #ここは飛び越える必要があるとき
    Snuke=[0 for i in range(N)]
    Fnuke=[0 for i in range(N)]
    Snuke[A]=1
    Fnuke[B]=1
    for i in range(1,N):
        if S[i]=="#":
            continue
        if Snuke[i-1]==1:
            Snuke[i]=1
        if i>1 and Snuke[i-2]==1:
            Snuke[i]=1
        if Fnuke[i-1]==1:
            Fnuke[i]=1
        if i>1 and Fnuke[i-2]==1:
            Fnuke[i]=1
    flag=0
    for i in range(C-2):
        if Snuke[i]*Snuke[i+1]*Snuke[i+2]*Fnuke[i]*Fnuke[i+1]*Fnuke[i+2]==1:
            flag=1
            break
    if Snuke[C]==1 and Fnuke[D]==1 and flag==1:
        print("Yes")
    else:
        print("No")