Problem p03017 (python)

Fixed submission:
#!/usr/bin/env python3

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

#hunuke

h = S[A-1:D+1].count('##')
m3 = S[B-2:D+1].count('...')

if C < D:
    if h == 0: print('Yes')
    else: print('No')
else:
    if m3 != 0 and h == 0:
        print('Yes')
    else: print('No')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

def move(S, before_a, before_b, a_index, b_index, g_a, g_b):
    try:
        if len(S)<=a_index or len(S) <= b_index:
            return -1
        if S[a_index]=='#' or S[a_index]=='B':
            return 0
        elif S[b_index]=='#' or S[b_index]=='A':
            return 0
        if a_index==g_a and b_index==g_b:
            return 100
    except:
        return -1


    rr1 = 0
    rr2 = 0
    rr3 = 0
    rr4 = 0
    try:
        S[before_a] = '.'
        S[before_b] = '.'
        S[a_index] = 'A'
        S[b_index] = 'B'
    except:
        return 0
    try:
        rr1 = move(S, a_index, b_index, a_index+1, b_index, g_a, g_b)
    except:
        pass
    try:
        rr2 = move(S, a_index, b_index, a_index+2, b_index, g_a, g_b)
    except:
        pass
    try:
        rr3 = move(S, a_index, b_index, a_index, b_index+1, g_a, g_b)
    except:
        pass
    try:
        rr4 = move(S, a_index, b_index, a_index, b_index+2, g_a, g_b)
    except:
        pass
    return max([rr1,rr2,rr3,rr4])

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

S = list(input())

S[A-1] = 'A'
S[B-1] = 'B'

a_index = A-1
b_index = B-1

r1 = 0
r2 = 0
r3 = 0
r4 = 0

if len(S)-1>a_index:
    r1 = move(S, a_index, b_index, a_index+1, b_index, C-1, D-1)
    if r1==100:
        print('Yes')
        exit()
if len(S)-2>a_index:
    r2 = move(S, a_index, b_index, a_index+2, b_index, C-1, D-1)
    if r2==100:
        print('Yes')
        exit()
if len(S)-1>b_index:
    r3 = move(S, a_index, b_index, a_index, b_index+1, C-1, D-1)
    if r3==100:
        print('Yes')
        exit()
if len(S)-2>b_index:
    r4 = move(S, a_index, b_index, a_index, b_index+2, C-1, D-1)
    if r4==100:
        print('Yes')
        exit()


print('No')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

def move(S, before_a, before_b, a_index, b_index, g_a, g_b):
    try:
        if len(S)<=a_index or len(S) <= b_index:
            return -1
    except:
        return -1
    if S[a_index]=='#' or S[a_index]=='B':
        return 0
    elif S[b_index]=='#' or S[b_index]=='A':
        return 0
    if a_index==g_a and b_index==g_b:
        return 100


    rr1 = 0
    rr2 = 0
    rr3 = 0
    rr4 = 0
    try:
        S[before_a] = '.'
        S[before_b] = '.'
        S[a_index] = 'A'
        S[b_index] = 'B'
    except:
        return 0
    try:
        rr1 = move(S, a_index, b_index, a_index+1, b_index, g_a, g_b)
    except:
        pass
    try:
        rr2 = move(S, a_index, b_index, a_index+2, b_index, g_a, g_b)
    except:
        pass
    try:
        rr3 = move(S, a_index, b_index, a_index, b_index+1, g_a, g_b)
    except:
        pass
    try:
        rr4 = move(S, a_index, b_index, a_index, b_index+2, g_a, g_b)
    except:
        pass
    return max([rr1,rr2,rr3,rr4])

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

S = list(input())

S[A-1] = 'A'
S[B-1] = 'B'

a_index = A-1
b_index = B-1

r1 = 0
r2 = 0
r3 = 0
r4 = 0

if len(S)-1>a_index:
    r1 = move(S, a_index, b_index, a_index+1, b_index, C-1, D-1)
    if r1==100:
        print('Yes')
        exit()
if len(S)-2>a_index:
    r2 = move(S, a_index, b_index, a_index+2, b_index, C-1, D-1)
    if r2==100:
        print('Yes')
        exit()
if len(S)-1>b_index:
    r3 = move(S, a_index, b_index, a_index, b_index+1, C-1, D-1)
    if r3==100:
        print('Yes')
        exit()
if len(S)-2>b_index:
    r4 = move(S, a_index, b_index, a_index, b_index+2, C-1, D-1)
    if r4==100:
        print('Yes')
        exit()


print('No')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

def move(S, before_a, before_b, a_index, b_index, g_a, g_b):
    if len(S)<=a_index or len(S) <= b_index:
        return -1
    if S[a_index]=='#' or S[a_index]=='B':
        return 0
    elif S[b_index]=='#' or S[b_index]=='A':
        return 0
    if a_index==g_a and b_index==g_b:
        return 100


    rr1 = 0
    rr2 = 0
    rr3 = 0
    rr4 = 0
    try:
        S[before_a] = '.'
        S[before_b] = '.'
        S[a_index] = 'A'
        S[b_index] = 'B'
    except:
        return 0
    try:
        rr1 = move(S, a_index, b_index, a_index+1, b_index, g_a, g_b)
    except:
        pass
    try:
        rr2 = move(S, a_index, b_index, a_index+2, b_index, g_a, g_b)
    except:
        pass
    try:
        rr3 = move(S, a_index, b_index, a_index, b_index+1, g_a, g_b)
    except:
        pass
    try:
        rr4 = move(S, a_index, b_index, a_index, b_index+2, g_a, g_b)
    except:
        pass
    return max([rr1,rr2,rr3,rr4])

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

S = list(input())

S[A-1] = 'A'
S[B-1] = 'B'

a_index = A-1
b_index = B-1

r1 = 0
r2 = 0
r3 = 0
r4 = 0

if len(S)-1>a_index:
    r1 = move(S, a_index, b_index, a_index+1, b_index, C-1, D-1)
    if r1==100:
        print('Yes')
        exit()
if len(S)-2>a_index:
    r2 = move(S, a_index, b_index, a_index+2, b_index, C-1, D-1)
    if r2==100:
        print('Yes')
        exit()
if len(S)-1>b_index:
    r3 = move(S, a_index, b_index, a_index, b_index+1, C-1, D-1)
    if r3==100:
        print('Yes')
        exit()
if len(S)-2>b_index:
    r4 = move(S, a_index, b_index, a_index, b_index+2, C-1, D-1)
    if r4==100:
        print('Yes')
        exit()


print('No')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

def move(S, before_a, before_b, a_index, b_index, g_a, g_b):
    if len(S)<=a_index or len(S) <= b_index:
        return -1
    if S[a_index]=='#' or S[a_index]=='B':
        return 0
    elif S[b_index]=='#' or S[b_index]=='A':
        return 0
    if a_index==g_a and b_index==g_b:
        return 100


    rr1 = 0
    rr2 = 0
    rr3 = 0
    rr4 = 0
    S[before_a] = '.'
    S[before_b] = '.'
    S[a_index] = 'A'
    S[b_index] = 'B'
    try:
        rr1 = move(S, a_index, b_index, a_index+1, b_index, g_a, g_b)
    except:
        pass
    try:
        rr2 = move(S, a_index, b_index, a_index+2, b_index, g_a, g_b)
    except:
        pass
    try:
        rr3 = move(S, a_index, b_index, a_index, b_index+1, g_a, g_b)
    except:
        pass
    try:
        rr4 = move(S, a_index, b_index, a_index, b_index+2, g_a, g_b)
    except:
        pass
    return max([rr1,rr2,rr3,rr4])

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

S = list(input())

S[A-1] = 'A'
S[B-1] = 'B'

a_index = A-1
b_index = B-1

r1 = 0
r2 = 0
r3 = 0
r4 = 0

if len(S)-1>a_index:
    r1 = move(S, a_index, b_index, a_index+1, b_index, C-1, D-1)
    if r1==100:
        print('Yes')
        exit()
if len(S)-2>a_index:
    r2 = move(S, a_index, b_index, a_index+2, b_index, C-1, D-1)
    if r2==100:
        print('Yes')
        exit()
if len(S)-1>b_index:
    r3 = move(S, a_index, b_index, a_index, b_index+1, C-1, D-1)
    if r3==100:
        print('Yes')
        exit()
if len(S)-2>b_index:
    r4 = move(S, a_index, b_index, a_index, b_index+2, C-1, D-1)
    if r4==100:
        print('Yes')
        exit()


print('No')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

def move(S, before_a, before_b, a_index, b_index, g_a, g_b):
    if len(S)<=a_index or len(S) <= b_index:
        return -1
    if S[a_index]=='#' or S[a_index]=='B':
        return 0
    elif S[b_index]=='#' or S[b_index]=='A':
        return 0
    if a_index==g_a and b_index==g_b:
        return 100
    S[before_a] = '.'
    S[before_b] = '.'

    S[a_index] = 'A'
    S[b_index] = 'B'
    rr1 = 0
    rr2 = 0
    rr3 = 0
    rr4 = 0
    rr1 = move(S, a_index, b_index, a_index+1, b_index, g_a, g_b)
    rr2 = move(S, a_index, b_index, a_index+2, b_index, g_a, g_b)
    rr3 = move(S, a_index, b_index, a_index, b_index+1, g_a, g_b)
    rr4 = move(S, a_index, b_index, a_index, b_index+2, g_a, g_b)
    return max([rr1,rr2,rr3,rr4])

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

S = list(input())

S[A-1] = 'A'
S[B-1] = 'B'

a_index = A-1
b_index = B-1

r1 = 0
r2 = 0
r3 = 0
r4 = 0

if len(S)-1>a_index:
    r1 = move(S, a_index, b_index, a_index+1, b_index, C-1, D-1)
    if r1==100:
        print('Yes')
        exit()
if len(S)-2>a_index:
    r2 = move(S, a_index, b_index, a_index+2, b_index, C-1, D-1)
    if r2==100:
        print('Yes')
        exit()
if len(S)-1>b_index:
    r3 = move(S, a_index, b_index, a_index, b_index+1, C-1, D-1)
    if r3==100:
        print('Yes')
        exit()
if len(S)-2>b_index:
    r4 = move(S, a_index, b_index, a_index, b_index+2, C-1, D-1)
    if r4==100:
        print('Yes')
        exit()


print('No')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

def move(S, before_a, before_b, a_index, b_index, g_a, g_b):
    if len(S)<=a_index or len(S) <= b_index:
        return -1
    if S[a_index]=='#' or S[a_index]=='B':
        return 0
    elif S[b_index]=='#' or S[b_index]=='A':
        return 0
    if a_index==g_a and b_index==g_b:
        return 100
    S[before_a] = '.'
    S[before_b] = '.'

    S[a_index] = 'A'
    S[b_index] = 'B'
    rr1 = 0
    rr2 = 0
    rr3 = 0
    rr4 = 0
    rr1 = move(S, a_index, b_index, a_index+1, b_index, g_a, g_b)
    rr2 = move(S, a_index, b_index, a_index+2, b_index, g_a, g_b)
    rr3 = move(S, a_index, b_index, a_index, b_index+1, g_a, g_b)
    rr4 = move(S, a_index, b_index, a_index, b_index+2, g_a, g_b)
    return max([rr1,rr2,rr3,rr4])
#    return 1

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

S = list(input())

S[A-1] = 'A'
S[B-1] = 'B'

a_index = A-1
b_index = B-1

r1 = 0
r2 = 0
r3 = 0
r4 = 0

if len(S)>a_index:
    r1 = move(S, a_index, b_index, a_index+1, b_index, C-1, D-1)
    if r1==100:
        print('Yes')
        exit()
if len(S)-1>a_index:
    r2 = move(S, a_index, b_index, a_index+2, b_index, C-1, D-1)
    if r2==100:
        print('Yes')
        exit()
if len(S)>b_index:
    r3 = move(S, a_index, b_index, a_index, b_index+1, C-1, D-1)
    if r3==100:
        print('Yes')
        exit()
if len(S)-1>b_index:
    r4 = move(S, a_index, b_index, a_index, b_index+2, C-1, D-1)
    if r4==100:
        print('Yes')
        exit()


print('No')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

def move(S, before_a, before_b, a_index, b_index, g_a, g_b):
    if len(S)<=a_index or len(S) <= b_index:
        return -1
    if S[a_index]=='#' or S[a_index]=='B':
        return 0
    elif S[b_index]=='#' or S[b_index]=='A':
        return 0
    if a_index==g_a and b_index==g_b:
        return 100
    S[before_a] = '.'
    S[before_b] = '.'

    S[a_index] = 'A'
    S[b_index] = 'B'
    rr1 = 0
    rr2 = 0
    rr3 = 0
    rr4 = 0
    rr1 = move(S, a_index, b_index, a_index+1, b_index, g_a, g_b)
    rr2 = move(S, a_index, b_index, a_index+2, b_index, g_a, g_b)
    rr3 = move(S, a_index, b_index, a_index, b_index+1, g_a, g_b)
    rr4 = move(S, a_index, b_index, a_index, b_index+2, g_a, g_b)
    return max([rr1,rr2,rr3,rr4])
#    return 1

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

S = list(input())

S[A-1] = 'A'
S[B-1] = 'B'

a_index = A-1
b_index = B-1

r1 = 0
r2 = 0
r3 = 0
r4 = 0

if len(S)>a_index:
    r1 = move(S, a_index, b_index, a_index+1, b_index, C-1, D-1)
    if r1==100:
        print('Yes')
        exit()
if len(S)-1>a_index:
    r2 = move(S, a_index, b_index, a_index+2, b_index, C-1, D-1)
    if r2==100:
        print('Yes')
        exit()
if len(S)>b_index:
    r3 = move(S, a_index, b_index, a_index, b_index+1, C-1, D-1)
    if r3==100:
        print('Yes')
        exit()
if len(S)-1>b_index:
    r4 = move(S, a_index, b_index, a_index, b_index+2, C-1, D-1)
    if r4==100:
        print('Yes')
        exit()
print('r1:{}, r2:{}, r3:{}, r4:{}'.format(r1,r2,r3,r4))


print('No')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

def move(S, before_a, before_b, a_index, b_index, g_a, g_b):
    if len(S)<=a_index or len(S) <= b_index:
        return -1
    if S[a_index]=='#' or S[a_index]=='B':
        return 0
    elif S[b_index]=='#' or S[b_index]=='A':
        return 0
    if a_index==g_a and b_index==g_b:
        return 100
    S[before_a] = '.'
    S[before_b] = '.'

    S[a_index] = 'A'
    S[b_index] = 'B'
    rr1 = 0
    rr2 = 0
    rr3 = 0
    rr4 = 0
    if len(S)-1>a_index:
        rr1 = move(S, a_index, b_index, a_index+1, b_index, g_a, g_b)
    if len(S)-2>a_index:
        rr2 =  move(S, a_index, b_index, a_index+2, b_index, g_a, g_b)
    if len(S)-1>b_index:
        rr3 = move(S, a_index, b_index, a_index, b_index+1, g_a, g_b)
    if len(S)-2>b_index:
        rr4 = move(S, a_index, b_index, a_index, b_index+2, g_a, g_b)
    return max([rr1,rr2,rr3,rr4])
#    return 1

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

S = list(input())

S[A-1] = 'A'
S[B-1] = 'B'

a_index = A-1
b_index = B-1

r1 = 0
r2 = 0
r3 = 0
r4 = 0

if len(S)>a_index:
    r1 = move(S, a_index, b_index, a_index+1, b_index, C-1, D-1)
if len(S)-1>a_index:
    r2 = move(S, a_index, b_index, a_index+2, b_index, C-1, D-1)
if len(S)>b_index:
    r3 = move(S, a_index, b_index, a_index, b_index+1, C-1, D-1)
if len(S)-1>b_index:
    r4 = move(S, a_index, b_index, a_index, b_index+2, C-1, D-1)


if r1==100 or r2==100 or r3==100 or r4==100:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

def move(S, before_a, before_b, a_index, b_index, g_a, g_b):
    if len(S)<=a_index or len(S) <= b_index:
        return -1
    if S[a_index]=='#' or S[a_index]=='B':
        return 0
    elif S[b_index]=='#' or S[b_index]=='A':
        return 0
    if a_index==g_a and b_index==g_b:
        return 100
    S[before_a] = '.'
    S[before_b] = '.'

    S[a_index] = 'A'
    S[b_index] = 'B'
    rr1 = 0
    rr2 = 0
    rr3 = 0
    rr4 = 0
    if len(S)>a_index:
        rr1 = move(S, a_index, b_index, a_index+1, b_index, g_a, g_b)
    if len(S)-1>a_index:
        rr2 =  move(S, a_index, b_index, a_index+2, b_index, g_a, g_b)
    if len(S)>b_index:
        rr3 = move(S, a_index, b_index, a_index, b_index+1, g_a, g_b)
    if len(S)-1>b_index:
        rr4 = move(S, a_index, b_index, a_index, b_index+2, g_a, g_b)
    return max([rr1,rr2,rr3,rr4])
#    return 1

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

S = list(input())

S[A-1] = 'A'
S[B-1] = 'B'

a_index = A-1
b_index = B-1

r1 = 0
r2 = 0
r3 = 0
r4 = 0

if len(S)>a_index:
    r1 = move(S, a_index, b_index, a_index+1, b_index, C-1, D-1)
if len(S)-1>a_index:
    r2 = move(S, a_index, b_index, a_index+2, b_index, C-1, D-1)
if len(S)>b_index:
    r3 = move(S, a_index, b_index, a_index, b_index+1, C-1, D-1)
if len(S)-1>b_index:
    r4 = move(S, a_index, b_index, a_index, b_index+2, C-1, D-1)


if r1==100 or r2==100 or r3==100 or r4==100:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

def move(S, before_a, before_b, a_index, b_index, g_a, g_b):
    if (len(S)>a_index and len(S) > b_index)==False:
        return -1
    if S[a_index]=='#' or S[a_index]=='B':
        return 0
    elif S[b_index]=='#' or S[b_index]=='A':
        return 0
    if a_index==g_a and b_index==g_b:
        return 100
    S[before_a] = '.'
    S[before_b] = '.'

    S[a_index] = 'A'
    S[b_index] = 'B'
    rr1 = 0
    rr2 = 0
    rr3 = 0
    rr4 = 0
    if len(S)>a_index:
        rr1 = move(S, a_index, b_index, a_index+1, b_index, g_a, g_b)
    if len(S)-1>a_index:
        rr2 =  move(S, a_index, b_index, a_index+2, b_index, g_a, g_b)
    if len(S)>b_index:
        rr3 = move(S, a_index, b_index, a_index, b_index+1, g_a, g_b)
    if len(S)-1>b_index:
        rr4 = move(S, a_index, b_index, a_index, b_index+2, g_a, g_b)
    return max([rr1,rr2,rr3,rr4])
#    return 1

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

S = list(input())

S[A-1] = 'A'
S[B-1] = 'B'

a_index = A-1
b_index = B-1

if len(S)>a_index:
    r1 = move(S, a_index, b_index, a_index+1, b_index, C-1, D-1)
if len(S)-1>a_index:
    r2 = move(S, a_index, b_index, a_index+2, b_index, C-1, D-1)
if len(S)>b_index:
    r3 = move(S, a_index, b_index, a_index, b_index+1, C-1, D-1)
if len(S)-1>b_index:
    r4 = move(S, a_index, b_index, a_index, b_index+2, C-1, D-1)


if r1==100 or r2==100 or r3==100 or r4==100:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

def move(S, before_a, before_b, a_index, b_index, g_a, g_b):
    if (len(S)>a_index and len(S) > b_index)==False:
        return -1
    if S[a_index]=='#' or S[a_index]=='B':
        return 0
    elif S[b_index]=='#' or S[b_index]=='A':
        return 0
    if a_index==g_a and b_index==g_b:
        return 100
    S[before_a] = '.'
    S[before_b] = '.'

    S[a_index] = 'A'
    S[b_index] = 'B'
    rr1 = 0
    rr2 = 0
    rr3 = 0
    rr4 = 0
    if len(S)>a_index:
        rr1 = move(S, a_index, b_index, a_index+1, b_index, g_a, g_b)
    if len(S)-1>a_index:
        rr2 =  move(S, a_index, b_index, a_index+2, b_index, g_a, g_b)
    if len(S)>b_index:
        rr3 = move(S, a_index, b_index, a_index, b_index+1, g_a, g_b)
    if len(S)-1>b_index:
        rr4 = move(S, a_index, b_index, a_index, b_index+2, g_a, g_b)
    return max([rr1,rr2,rr3,rr4])
#    return 1

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

S = list(input())

S[A-1] = 'A'
S[B-1] = 'B'

a_index = A-1
b_index = B-1

r1 = move(S, a_index, b_index, a_index+1, b_index, C-1, D-1)
r2 = move(S, a_index, b_index, a_index+2, b_index, C-1, D-1)
r3 = move(S, a_index, b_index, a_index, b_index+1, C-1, D-1)
r4 = move(S, a_index, b_index, a_index, b_index+2, C-1, D-1)


if r1==100 or r2==100 or r3==100 or r4==100:
    print('Yes')
else:
    print('No')