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:
# https://atcoder.jp/contests/agc034/tasks/agc034_a

import itertools
from collections import Counter
from collections import defaultdict
import bisect
import math
import heapq

def main():
    N, A, B, C, D = map(int, input().split())
    S = list(input())

    blocks = 0
    for s in range(A - 1, C - 1):
        if S[s] == '.':
            if blocks > 1:
                print('No')
                exit()
            blocks = 0
        else:
            blocks += 1

    blocks = 0
    for s in range(B - 1, D - 1):
        if S[s] == '.':
            if blocks > 1:
                print('No')
                exit()
            blocks = 0
        else:
            blocks += 1

    if D < C:  # 追い越す場所が必要
        can_overtake = False
        for s in range(B - 1, D - 1):
            if S[s-1] == '.' and S[s] == '.' and S[s+1] == '.':
                can_overtake = True
                break

        if not can_overtake:
            print('No')
            exit()

    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc034/tasks/agc034_a

import itertools
from collections import Counter
from collections import defaultdict
import bisect
import math
import heapq

def main():
    N, A, B, C, D = map(int, input().split())
    S = list(input())

    blocks = 0
    for s in range(A - 1, C - 1):
        if S[s] == '.':
            if blocks > 1:
                print('No')
                exit()
            blocks = 0
        else:
            blocks += 1

    blocks = 0
    for s in range(B - 1, D - 1):
        if S[s] == '.':
            if blocks > 1:
                print('No')
                exit()
            blocks = 0
        else:
            blocks += 1

    if D < C:  # 追い越す場所が必要
        can_overtake = False
        spaces = 0
        for s in range(B - 2, D):
            if S[s] == '#':
                if spaces > 2:
                    can_overtake = True
                    break
                spaces = 0
            else:
                spaces += 1
        if spaces > 2:
            can_overtake = True

        if not can_overtake:
            print('No')
            exit()

    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc034/tasks/agc034_a

import itertools
from collections import Counter
from collections import defaultdict
import bisect
import math
import heapq

def main():
    N, A, B, C, D = map(int, input().split())
    S = list(input())

    blocks = 0
    for s in range(A - 1, C - 1):
        if S[s] == '.':
            if blocks > 1:
                print('No')
                exit()
            blocks = 0
        else:
            blocks += 1

    blocks = 0
    for s in range(B - 1, D - 1):
        if S[s] == '.':
            if blocks > 1:
                print('No')
                exit()
            blocks = 0
        else:
            blocks += 1

    if D < C:  # 追い越す場所が必要
        can_overtake = False
        spaces = 0
        for s in range(B - 2, D):
            if S[s] == '#':
                if spaces > 2:
                    can_overtake = True
                    break
                spaces = 0
            else:
                spaces += 1
        if not can_overtake:
            print('No')
            exit()

    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc034/tasks/agc034_a

import itertools
from collections import Counter
from collections import defaultdict
import bisect
import math
import heapq

def main():
    N, A, B, C, D = map(int, input().split())
    S = list(input())

    blocks = 0
    for s in range(A - 1, C - 1):
        if S[s] == '.':
            if blocks > 1:
                print('No')
                exit()
            blocks = 0
        else:
            blocks += 1

    blocks = 0
    for s in range(B - 1, D - 1):
        if S[s] == '.':
            if blocks > 1:
                print('No')
                exit()
            blocks = 0
        else:
            blocks += 1

    if D < C:  # 追い越す場所が必要
        can_overtake = False
        spaces = 0
        for s in range(B - 1, D - 1):
            if S[s] == '#':
                if spaces > 2:
                    can_overtake = True
                    break
                spaces = 0
            else:
                spaces += 1
        if not can_overtake:
            print('No')
            exit()

    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
A - Kenken Race
https://atcoder.jp/contests/agc034/tasks/agc034_a

"""
import sys


def solve(N, A, B, C, D, S):
    p_A = set([A])
    for p, n1, n2 in zip(range(A, C), S[A+1:], S[A+2:]):
        if p in p_A:
            if n1 == '.' and p+1:
                p_A.add(p+1)
            if n2 == '.' and p+2:
                p_A.add(p+2)

    p_B = set([B])
    for p, n1, n2 in zip(range(B, D), S[B+1:], S[B+2:]):
        if p in p_B:
            if n1 == '.' and p+1:
                p_B.add(p+1)
            if n2 == '.' and p+2:
                p_B.add(p+2)

    p_t = set()
    for p, p1, p2, p3 in zip(range(B, N+1), S[B:D+1], S[B+1:], S[B+2:]):
        if p1 == '.' and p2 == '.' and p3 == '.':
            p_t.add(p)

    if C < D:
        if C in p_A and D in p_B:
            return 'Yes'
        return 'No'
    else:
        if (C in p_A) and (D in p_B) and (p_A and p_t) and (p_B and p_t):
            return 'Yes'
        return 'No'


def main(args):
    N, A, B, C, D = map(int, input().split())
    S = input()
    S = '#' + S + '##'
    ans = solve(N, A, B, C, D, S)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc034/tasks/agc034_a

import itertools
from collections import Counter
from collections import defaultdict
import bisect
import math
import heapq

def main():
    N, A, B, C, D = map(int, input().split())
    S = list(input())

    blocks = 0
    for s in range(A - 1, max(C, D) - 1):
        if S[s] == '.':
            if blocks > 1:
                print('No')
                exit()
            blocks = 0
        else:
            blocks += 1

    if D < C:  # 追い越す場所が必要
        can_overtake = False
        spaces = 0
        for s in range(B - 1, min(C, D) - 1):
            if S[s] == '#':
                if spaces > 2:
                    can_overtake = True
                    break
                spaces = 0
            else:
                spaces += 1
        if not can_overtake:
            print('No')
            exit()

    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
A - Kenken Race
https://atcoder.jp/contests/agc034/tasks/agc034_a

"""
import sys


def solve(N, A, B, C, D, S):
    p_A = set([A])
    for p, n1, n2 in zip(range(A, C), S[A+1:], S[A+2:]):
        if p in p_A:
            if n1 == '.' and p+1:
                p_A.add(p+1)
            if n2 == '.' and p+2:
                p_A.add(p+2)

    p_B = set([B])
    for p, n1, n2 in zip(range(B, D), S[B+1:], S[B+2:]):
        if p in p_B:
            if n1 == '.' and p+1:
                p_B.add(p+1)
            if n2 == '.' and p+2:
                p_B.add(p+2)

    p_t = set()
    for p, p1, p2, p3 in zip(range(B, N+1), S[B:D], S[B+1:], S[B+2:]):
        if p1 == '.' and p2 == '.' and p3 == '.':
            p_t.add(p)

    if C < D:
        if C in p_A and D in p_B:
            return 'Yes'
        return 'No'
    else:
        if (C in p_A) and (D in p_B) and (p_A and p_t) and (p_B and p_t):
            return 'Yes'
        return 'No'


def main(args):
    N, A, B, C, D = map(int, input().split())
    S = input()
    S = '#' + S + '##'
    ans = solve(N, A, B, C, D, S)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

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 gen_li(s,st,fi):
    lia=[]
    tmp=s[st+1]
    tmpn=1
    for i in s[st+2:fi]:
        if tmp==i:
            tmpn+=1
        else:
            if tmp=="#":
                sign=-1
            else:
                sign=1
            lia.append(sign*tmpn)

            tmp=i
            tmpn=1
    return lia


def func(t,a,b,c,d,s):
    lil1=[]
    lil2=[]
    
    if t==0 :
        lil1=gen_li(s,min(a,b),max(a,b))+gen_li(s,min(c,d),max(c,d))
        if len(lil1)>0:
            if min(lil1)<-1 :
                return ("No")
        lil2=gen_li(s,max(a-1,b-1),min(c+1,d+1))
        if len(lil2)>0:
            if min(lil2)<-1 or max(lil2)<3:
                return ("No")

    elif t==1:
        lil1=gen_li(s,min(a,b),min(c,d))
        if min(lil1)<-1:
            return ("No")   
        lil2=gen_li(s,min(a,b),min(c,d))
        if min(lil2)<-1:
            return ("No")
        
    return("Yes")


if c<b or d<a:
    t=1
else:
    t=0
    

    

ans=func(t,a,b,c,d,s)
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
A - Kenken Race
https://atcoder.jp/contests/agc034/tasks/agc034_a

"""
import sys


def solve(N, A, B, C, D, S):
    p_A = set([A])
    for p, n1, n2 in zip(range(A, C+1), S[A+1:], S[A+2:]):
        if p in p_A:
            if n1 == '.' and p+1:
                p_A.add(p+1)
            if n2 == '.' and p+2:
                p_A.add(p+2)

    p_B = set([B])
    for p, n1, n2 in zip(range(B, D+1), S[B+1:], S[B+2:]):
        if p in p_B:
            if n1 == '.' and p+1:
                p_B.add(p+1)
            if n2 == '.' and p+2:
                p_B.add(p+2)

    p_t = set()
    for p, p1, p2, p3 in zip(range(N+1), S[B:D], S[B+1:], S[B+2:]):
        if p1 == '.' and p2 == '.' and p3 == '.':
            p_t.add(p)

    if C < D:
        if C in p_A and D in p_B:
            return 'Yes'
        return 'No'
    else:
        if C in p_A and D in p_B and p_A and p_t and p_B and p_t:
            return 'Yes'
        return 'No'


def main(args):
    N, A, B, C, D = map(int, input().split())
    S = input()
    S = '#' + S + '#'
    ans = solve(N, A, B, C, D, S)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
A - Kenken Race
https://atcoder.jp/contests/agc034/tasks/agc034_a

"""
import sys


def solve(N, A, B, C, D, S):
    p_A = set([A])
    for p, n1, n2 in zip(range(A, N+1), S[A+1:], S[A+2:]):
        if p in p_A:
            if n1 == '.':
                p_A.add(p+1)
            if n2 == '.':
                p_A.add(p+2)

    p_B = set([B])
    for p, n1, n2 in zip(range(B, N+1), S[B+1:], S[B+2:]):
        if p in p_B:
            if n1 == '.':
                p_B.add(p+1)
            if n2 == '.':
                p_B.add(p+2)

    p_t = set()
    for p, p1, p2, p3 in zip(range(N+1), S[B:D], S[B+1:], S[B+2:]):
        if p1 == '.' and p2 == '.' and p3 == '.':
            p_t.add(p)

    if C < D:
        if C in p_A and D in p_B:
            return 'Yes'
        return 'No'
    else:
        if C in p_A and D in p_B and p_A and p_t and p_B and p_t:
            return 'Yes'
        return 'No'


def main(args):
    N, A, B, C, D = map(int, input().split())
    S = input()
    S = '#' + S + '#'
    ans = solve(N, A, B, C, D, S)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
A - Kenken Race
https://atcoder.jp/contests/agc034/tasks/agc034_a

"""
import sys


def solve(N, A, B, C, D, S):
    p_A = set([A])
    p_B = set([B])

    for p, n1, n2 in zip(range(A, N+1), S[A+1:], S[A+2:]):
        if p in p_A:
            if n1 == '.':
                p_A.add(p+1)
            if n2 == '.':
                p_A.add(p+2)
    T = (S[:A])[::-1]
    for p, n1, n2 in zip(range(A, 0, -1), T, T[1:]):
        if p in p_A:
            if n1 == '.':
                p_A.add(p-1)
            if n2 == '.':
                p_A.add(p-2)

    for p, n1, n2 in zip(range(B, N+1), S[B+1:], S[B+2:]):
        if p in p_B:
            if n1 == '.':
                p_B.add(p+1)
            if n2 == '.':
                p_B.add(p+2)
    T = (S[:B])[::-1]
    for p, n1, n2 in zip(range(B, 0, -1), T, T[1:]):
        if p in p_B:
            if n1 == '.':
                p_B.add(p-1)
            if n2 == '.':
                p_B.add(p-2)

    p_t = set()
    S = S + '##'
    for p, p1, p2, p3 in zip(range(N+1), S, S[1:], S[2:]):
        if p1 == '.' and p2 == '.' and p3 == '.':
            p_t.add(p)

    if C < D:
        if C in p_A and D in p_B:
            return 'Yes'
        return 'No'
    else:
        if C in p_A and D in p_B and p_A and p_t and p_B and p_t:
            return 'Yes'
        return 'No'


def main(args):
    N, A, B, C, D = map(int, input().split())
    S = input()
    S = '#' + S + '#'
    ans = solve(N, A, B, C, D, S)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Wrong Answer

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

if C<D:
	if "##"  in S[B-1:D]:
		print "No"
		quit()
	if "##" in S[A-1:C]:
		print "No"
		quit()
	print "Yes"
elif D<C:
	if "##" in S[A-1:C]:
		print "No"
		quit()

	if "..." in S[B-2:D]:
		print "Yes"
		quit()
	print "No"

Submission status: Wrong Answer

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

if C<D:
	if "##"  in S[B-1:D]:
		print "No"
		quit()
	if "##" in S[A-1:C]:
		print "No"
		quit()
	print "Yes"
elif D<C:
	if "##" in S[A-1:C]:
		print "No"
		quit()

	if "..." in S[B-1:D]:
		print "Yes"
		quit()
	print "No"

Submission status: Wrong Answer

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

if C<D:
	if "##"  in S[B-1:D]:
		print "No"
		quit()
	if "##" in S[A-1:C]:
		print "No"
		quit()
	print "Yes"
elif D<C:
	if "##" in S[A-1:C]:
		print "No"
		quit()

	if "..." in S[B-1:D]:
		print "Yes"
		quit()

	print "No"

Submission status: Wrong Answer

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

if C<D:
	if "##"  in S[B-1:D]:
		print "No"
		quit()
	if "##" in S[A-1:C]:
		print "No"
		quit()
	print "Yes"
elif D<C:
	if "##" in S[A-1:C]:
		print "No"
		quit()

	if not "..." in S[B-1:D]:
		print "No"
		quit()

	print "Yes"

Submission status: Wrong Answer

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

multi = False
excha = False
for i in range(D-3,B-2,-1):
  if S[i] == '#' and S[i+1] == '#':
    multi = True
  if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
    excha = True
if multi:
  Ans = "No"
if not excha:
  S.pop(D-1)
  S.insert(D-1,'#')

multi = False
for i in range(C-3,A-1,-1):
  if S[i] == '#' and S[i+1] == '#':
    multi = True
if multi:
  Ans = "No"

print(Ans)

Submission status: Wrong Answer

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

begin=min(A,B,C,D)
end=max(A,B,C,D)

if C<D:
	if "##" in S[begin-1 : end]:
		print "No"
		quit()
	print "Yes"
elif D<C:
	if "##" in S[begin-1 : end]:
		print "No"
		quit()

	if not "..." in S[B-1:D]:
		print "No"
		quit()

	print "Yes"

Submission status: Wrong Answer

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

begin=min(A,B,C,D)
end=max(A,B,C,D)

if C<D:
	if "##" in S[begin-1 : end]:
		print "No"
		quit()
	print "Yes"
elif D<C:
	if "##" in S[begin-1 : end]:
		print "No"
		quit()

	if not "..." in S[B:D]:
		print "No"
		quit()

	print "Yes"

Submission status: Wrong Answer

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

begin=min(A,B,C,D)
end=max(A,B,C,D)

if C<D:
	if "##" in S[begin-1 : end]:
		print "No"
		quit()
	print "Yes"
elif D<C:
	if "##" in S[begin-1 : end]:
		print "No"
		quit()

	str=S[B:D]
	if "..." in str and "##" not in str:
		pass
	else:
		print "No"
		quit()

	print "Yes"

Submission status: Wrong Answer

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

multi = False
excha = False
for i in range(D-3,B-1,-1):
  if S[i] == '#' and S[i+1] == '#':
    multi = True
  if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
    excha = True
if multi:
  Ans = "No"
if not excha:
  S.pop(D-1)
  S.insert(D-1,'#')

multi = False
for i in range(C-3,A-1,-1):
  if S[i] == '#' and S[i+1] == '#':
    multi = True
if multi:
  Ans = "No"

print(Ans)

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(lambda x: int(x)-1, input().split())
L = input()
reachable = not "##" in L[A:C+1] or "##" in L[B:D+1]
interupt = "..." in L[B-1:D+2]
if reachable and (C < D or interupt):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(lambda x: int(x)-1, input().split())
L = input()
reachable = "##" in L[A:C+1] or "##" in L[B:D+1]
interupt = "..." in L[B-1:D+2]
if reachable and (C < D or interupt):
    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[a - 1:c] and "##" in s[b - 1:d]:
    judge = False
else:
    judge = True

if judge and c > d:
    if "..." in s[b - 2:d + 1]:
        judge = True
    else:
        judge = False

print("Yes") if judge else print('No')

Submission status: Wrong Answer

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

if C<D:
	if "##"  in S[B-1:D]:
		print "No"
		quit()
	if "##" in S[A-1:C]:
		print "No"
		quit()
	print "Yes"
elif D<C:
	str=S[B:D]
	if "..." in str and "##" not in str:
		pass
	else:
		print "No"
		quit()

	print "Yes"

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys

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

reachable = True
if "##" in L[A:C+1] or "##" in L[B:D+1]:
    reachable = True

if not reachable:
    print("No")
elif C < D:
    print("Yes")
else:
    if "..." in L[B-1:D+2]:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys

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

reachable = True
if "##" in L[A:C+1] or "##" in L[B:D+1]:
    reachable = True

if not reachable:
    print("No")
elif C < D:
    print("Yes")
else:
    if "..." in L[B-1:D+1]:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

if C<D:
	if "##"  in S[B-1:D]:
		print "No"
		quit()
	if "##" in S[A-1:C]:
		print "No"
		quit()
	print "Yes"
elif D<C:
	str=S[B-1:D]
	if "..." in str and "##" not in str:
		pass
	else:
		print "No"
		quit()

	print "Yes"

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys

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

reachable = True
if "##" in L[A:C+1] or "##" in L[B:D+1]:
    reachable = True

if not reachable:
    print("No")
elif C < D:
    print("Yes")
else:
    if "..." in L[B-1:min(C, D)+1]:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys

N, A, B, C, D = map(int, input().split())
L = list([v for v in input()])

HOP = [1, 2]
dp_d = [0]*N
dp_d[B-1] = 1
for i in range(N):
    if L[i] == "#":
        continue
    for h in HOP:
        dst = i+h
        if dst < N and L[dst] == ".":
            dp_d[dst] = max(dp_d[dst], dp_d[i])
dp_c = [0]*N
dp_c[A-1] = 1
for i in range(N):
    if L[i] == "#":
        continue
    for h in HOP:
        dst = i+h
        if dst < N and L[dst] == ".":
            dp_c[dst] = max(dp_c[dst], dp_c[i])
reachable = False
if dp_c[C-1] == 1 and dp_d[D-1] == 1:
    reachable = True

if not reachable:
    print("No")
elif C < D:
    print("Yes")
else:
    if "..." in "".join(L[B-2:min(C, D)]):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
S = [1] + [1 if s == "." else 0 for s in input()]
flag = True
count = 0
for s,i in zip(S[1:],range(1,n+1)):
    if not(s):
        count += 1
    else:
        count = 0
    if count == 2 and a < i and i < c:
        flag = False
        break
    elif count == 2 and b < i and i < d:
        flag = False
        break
count = 0
if  c > d:
    flag = False
    for s in S[b:d+2]:
        if s:
            count += 1
        else:
            count = 0
        if count == 3:
            flag = True
            break
if flag :
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys

N, A, B, C, D = map(int, input().split())
L = list([v for v in input()])

HOP = [1, 2]
dp_d = [0]*N
dp_d[B-1] = 1
for i in range(N):
    if L[i] == "#":
        continue
    for h in HOP:
        dst = i+h
        if dst < N and L[dst] == ".":
            dp_d[dst] = max(dp_d[dst], dp_d[i])
dp_c = [0]*N
dp_c[A-1] = 1
for i in range(N):
    if L[i] == "#":
        continue
    for h in HOP:
        dst = i+h
        if dst < N and L[dst] == ".":
            dp_c[dst] = max(dp_c[dst], dp_c[i])
reachable = False
if dp_c[C-1] == 1 and dp_d[D-1] == 1:
    reachable = True

if not reachable:
    print("No")
elif C < D:
    print("Yes")
else:
    if "..." in "".join(L[B-1:max(C, D)-1]):
        print("Yes")
    else:
      print("No")

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys

N, A, B, C, D = map(int, input().split())
L = list([v for v in input()])

HOP = [1, 2]
dp_d = [0]*N
dp_d[B-1] = 1
for i in range(N):
    if L[i] == "#":
        continue
    for h in HOP:
        dst = i+h
        if dst < N and L[dst] == ".":
            dp_d[dst] = max(dp_d[dst], dp_d[i])
dp_c = [0]*N
dp_c[A-1] = 1
for i in range(N):
    if L[i] == "#":
        continue
    for h in HOP:
        dst = i+h
        if dst < N and L[dst] == ".":
            dp_c[dst] = max(dp_c[dst], dp_c[i])
reachable = False
if dp_c[C-1] == 1 and dp_d[D-1] == 1:
    reachable = True

if not reachable:
    print("No")
elif C < D:
    print("Yes")
else:
    if "..." in "".join(L[B-1:max(C, D)-1]):
        print("Yes")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
if "##" in s[a-1:c-1] and "##" in s[b-1:d-1]:
    judge = False
else:
    judge = True

if judge and c > d:
    if "..." in s[b - 1:d + 1]:
        judge = True
    else:
        judge = False

print("Yes") if judge else print('No')

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys

N, A, B, C, D = map(int, input().split())
L = list([v for v in input()])

HOP = [1, 2]
dp_d = [0]*N
dp_d[B-1] = 1
for i in range(N):
    if L[i] == "#":
        continue
    for h in HOP:
        dst = i+h
        if dst < N and L[dst] == ".":
            dp_d[dst] = max(dp_d[dst], dp_d[i])
dp_c = [0]*N
dp_c[A-1] = 1
for i in range(N):
    if L[i] == "#":
        continue
    for h in HOP:
        dst = i+h
        if dst < N and L[dst] == ".":
            dp_c[dst] = max(dp_c[dst], dp_c[i])
reachable = False
if dp_c[C-1] == 1 and dp_d[D-1] == 1:
    reachable = True

if not reachable:
    print("No")
elif C < D:
    print("Yes")
else:
    if "..." in "".join(L):
        print("Yes")
    else:
      print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
S = [1] + [1 if s == "." else 0 for s in input()]
flag = True
count = 0
for s,i in zip(S[1:],range(1,n+1)):
    if not(s):
        count += 1
    else:
        count = 0
    if count == 2 and a < i and i < c:
        flag = False
        break
    elif count == 2 and b < i and i < d:
        flag = False
        break
count = 0
if  c > d:
    flag = False
    for s in S[b:d+1]:
        if s:
            count += 1
        else:
            count = 0
        if count == 3:
            flag = True
            break
if flag :
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys

N, A, B, C, D = map(int, input().split())
L = list([v for v in input()])

HOP = [1, 2]
if True:
    dp_d = [0]*N
    dp_d[B-1] = 1
    for i in range(N):
        if L[i] == "#":
            continue
        for h in HOP:
            dst = i+h
            if dst < N and L[dst] == ".":
                dp_d[dst] = max(dp_d[dst], dp_d[i])
    dp_c = [0]*N
    dp_c[A-1] = 1
    for i in range(N):
        if L[i] == "#":
            continue
        for h in HOP:
            dst = i+h
            if dst < N and L[dst] == ".":
                dp_c[dst] = max(dp_c[dst], dp_c[i])
    if dp_c[C-1] == 1 and dp_d[D-1] == 1:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys

N, A, B, C, D = map(int, input().split())
L = list([v for v in input()])

HOP = [1, 2]
if C < D:
    dp_d = [0]*N
    dp_d[B-1] = 1
    for i in range(N):
        if L[i] == "#":
            continue
        for h in HOP:
            dst = i+h
            if dst < N and L[dst] == ".":
                dp_d[dst] = max(dp_d[dst], dp_d[i])
    dp_c = [0]*N
    dp_c[A-1] = 1
    for i in range(N):
        if L[i] == "#":
            continue
        for h in HOP:
            dst = i+h
            if dst < N and L[dst] == ".":
                dp_c[dst] = max(dp_c[dst], dp_c[i])
    if dp_c[C-1] == 1 and dp_d[D-1] == 1:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
S = [1] + [1 if s == "." else 0 for s in input().split()]
flag = True
count = 0
for s,i in zip(S[1:],range(1,n+1)):
    if not(s):
        count += 1
    else:
        count = 0
    if count == 2 and a < i and i < c:
        flag = False
        break
    elif count == 2 and b < i and i < d:
        flag = False
        break
count = 0
if  c > d:
    flag = False
    for s in S[b:d+1]:
        if s:
            count += 1
        else:
            count = 0
        if count == 3:
            flag = True
            break
if flag :
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

if C<D:
	if "##"  in S[B-1:D]:
		print "No"
		quit()
	if "##" in S[A-1:C]:
		print "No"
		quit()
	print "Yes"
elif D<C:
	str=S[B-1:D]
	if "..." in str and "##" not in str:
		pass
	else:
		print "No"
		quit()

	if "##" in S[A-1:B] or  "##" in S[D-1:C]:
		print "No"
		quit()
	print "Yes"

Submission status: Wrong Answer

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

if C<D:
	if "##"  in S[B-1:D]:
		print "No"
		quit()
	if "##" in S[A-1:C]:
		print "No"
		quit()
	print "Yes"
elif D<C:
	print "Yes"

Submission status: Wrong Answer

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

if C<D:
	if "##"  in S[B-1:D]:
		print "No"
		quit()
	if "##" in S[A-1:C]:
		print "No"
		quit()
	print "Yes"
elif D<C:
	str=S[B-1:D]
	if "..." in str and "##" not in str:
		pass
	else:
		print "No"
		quit()

	if "##" in S[A-1:C]:
		print "No"
		quit()
	print "Yes"

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if C<D:
	if "##"  in S[B-1:D]:
		print "No"
		quit()
	if "##" in S[A-1:C]:
		print "No"
		quit()
	print "Yes"
elif D<C:
	str=S[B-1:D]
	if "..." in str and "##" not in str:
		pass
	else:
		print "No"
		quit()

	if "##" in S[A-1:B] or "##" in S[D:C]:
		print "No"
		quit()
	print "Yes"

Submission status: Wrong Answer

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

if C<D:
	if "##"  in S[B-1:D]:
		print "No"
		quit()
	if "##" in S[A-1:C]:
		print "No"
		quit()
	print "Yes"
elif D<C:
	if "##" in S[A-1:B] or "##" in S[D:C]:
		print "No"
		quit()
	str=S[B-1:D]
	if "..." in str and "##" not in str:
		print "Yes"
	else:
		print "No"

Submission status: Wrong Answer

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

if C<D:
	if "##"  in S[B-1:D]:
		print "No"
		quit()
	if "##" in S[A-1:C]:
		print "No"
		quit()
	print "Yes"
elif D<C:
	if "##" in S[A-1:B] or "##" in S[D-1:C]:
		print "No"
		quit()
	str=S[B-1:D]
	if "..." in str and "##" not in str:
		print "Yes"
	else:
		print "No"

Submission status: Wrong Answer

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

if C<D:
	if "##"  in S[B-1:D]:
		print "No"
		quit()
	if "##" in S[A-1:C]:
		print "No"
		quit()
	print "Yes"
elif D<C:
	if "##" in S[A-1:C]:
		print "No"
		quit()
	str=S[B-1:D]
	if "..." in str and "##" not in str:
		print "Yes"
	else:
		print "No"

Submission status: Wrong Answer

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

if C<D:
	if "##"  in S[B-1:D]:
		print "No"
		quit()
	if "##" in S[A-1:C]:
		print "No"
		quit()
	print "Yes"
elif D<C:
	str=S[B-1:D]
	if "..." in str and "##" not in str:
		print "Yes"
	else:
		print "No"

Submission status: Wrong Answer

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

if C<D:
	if "##"  in S[B-1:D]:
		print "No"
		quit()
	if "##" in S[B-1:D]:
		print "No"
		quit()
	print "Yes"
elif D<C:
	str=S[B-1:D]
	if "..." in str and "##" not in str:
		print "Yes"
	else:
		print "No"

Submission status: Wrong Answer

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

if C<D:
	if "##"  in S[B-1:D]:
		print "No"
		quit()
	if "##" in S[B-1:D]:
		print "No"
		quit()
	print "Yes"
elif D<C:
	if "...." in S[B-1:D] and "##" not in S[B-1:D]:
		print "Yes"
	else:
		print "No"

Submission status: Wrong Answer

Solution code:
def b():
    import re
    s = input()
    s = re.sub(r'BC', 'D', s)
    ls = range(len(s))
    ac, c = 0, 0
    for i in ls:
        if s[i] == 'A':
            ac += 1
        elif s[i] == 'D':
            c += ac
        else:
            ac = 0
    return c


ans = b()
print(ans)