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:
import sys

n, a, b, c, d = list(map(int, input().split()))
s = input()
sd = s[b - 1:c + 1]
t = 0  # \#
u = 0  # .
for si in sd:
    if si == ".":
        u += 1
        t = 0
    elif si == "#":
        t += 1
        u = 0

    if u == 3:
        print("Yes")
        sys.exit()
    if t == 2:
        print("No")
        sys.exit()

if c < d:
    print("Yes")
    sys.exit()

if s[d - 2] == "#" or (d < n and s[d] == "#"):
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D =map(int,input().split())
S = input()[min(A,B):max(C,D) + 1]

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

Submission status: Wrong Answer

Solution code:


from math import *

n,a,b,c,d=map(int,input().split(" "))

s=input()


flg=0


for i in range(b,d):
	if(s[i]=='#' and s[i-1]==s[i]):
		flg=1

for i in range(a,c):
	if(s[i]=='#' and s[i-1]==s[i]):
		flg=1

if(c>d):
	ff=1
	for i in range(b+1,d):
		if(s[i]=='.' and s[i-1]=='.' and s[i-2]=='.'):
			ff=0
	if(ff):
		flg=1

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

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int,input().split())
st = input()
if C == D :
  print("No")
elif C < D:#連続で岩が置かれていなければおっけー
  flag = 0
  st1 = st[A:C+1]
  for i in range(len(st1)-1):
    if st1[i:i+2] == "##":
      flag = 1
      
  st1 = st[B:D+1]
  for i in range(len(st1)-1):
    if st1[i:i+2] == "##":
      flag = 1
  if flag :
    print("No")
  else:
    print("Yes")
    
else:#入れ替わりを行う必要がある
  flag = 0
  irekaeble = 0
  st1 = st[A:C+1]
  for i in range(len(st1)-1):
    if st1[i:i+2] == "##":
      flag = 1
      
  st1 = st[B:D+1]
  for i in range(len(st1)-1):
    if st1[i:i+2] == "##":
      flag = 1
      
  st1 = st[B-1:C+1]
  for i in range(len(st)-2):
    if st1[i:i+3] == "...":
      irekaeble = 1
  
  if flag or irekaeble == 0:
    print("No")
  else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
#import numpy as np

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, A, B, C, D = i2nn()
    S = i2s()

    s1 = S[A:C-1]
    s2 = S[B:D-1]
    if s1.find('##') >= 0 or s2.find('##') >= 0:
        print('No')
        return

    if C < D:
        print('Yes')
        return
    else:
        s3 = S[B-1:C]
        if s3.find('...') >= 0:
            print('Yes')
            return
        print('No')
        return

main()

Submission status: Wrong Answer

Solution code:
def getlist():
	return map(int, input().split())

N, A, B, C, D = getlist()
S = list(input())

a = A - 1
b = B - 1
c = C - 1
d = D - 1

if c < b:
	judge1 = "YES"
	j = 0
	val = 0
	for i in range(a, c):
		if S[i] == ".":
			val = 0
		else:
			val += 1
			if val > j:
				j = val
	if j >= 2:
		judge1 = "NO"

	judge2 = "YES"
	j = 0
	val = 0
	for i in range(b, d):
		if S[i] == ".":
			val = 0
		else:
			val += 1
			if val > j:
				j = val
	if j >= 2:
		judge2 = "NO"

	if judge1 == "YES" and judge2 == "YES":
		print("Yes")
	else:
		print("No")


elif c < d:
	judge = "Yes"
	j = 0
	val = 0
	for i in range(a, d):
		if S[i] == ".":
			val = 0
		else:
			val += 1
			if val > j:
				j = val
	if j >= 2:
		judge = "No"
	print(judge)

else:
	judge1 = "YES"
	j = 0
	val = 0
	for i in range(a, c):
		if S[i] == ".":
			val = 0
		else:
			val += 1
			if val > j:
				j = val
	if j >= 2:
		judge1 = "NO"

	judge2 = "YES"
	j = 0
	val = 0
	for i in range(a, c + 1):
		if S[i] == "#":
			val = 0
		else:
			val += 1
			if val > j:
				j = val
	if j <= 2:
		judge2 = "NO"

	if judge1 == "YES" and judge2 == "YES":
		print("Yes")
	else:
		print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()+"#"
e,f=True,False
for i in range(n-1):
    if s[i]+s[i+1]=="#"*2:
        if a<i<d:
            print("No")
            break
    else:
        if s[i]+s[i+1]+s[i+2]=="."*3:
            if b<=i+1<=d:
                f=True
else:
    if c<d:
        print("Yes")
    else:
        if f:
            print("Yes")
        else:
            print("No")

Submission status: Wrong Answer

Solution code:
# from sys import exit
N, A, B, C, D = [int(n)-1 for n in input().split()]
# N = int(input())
# a = [int(input()) for _ in range(N)]
S = list(str(input()))
L = len(S)
# T = str(input())
# # exit()
# S[A] = "A"
# S[B] = "B"
# S[C] = "AG"
# S[D] = "BG"
# print(S)
# 連続岩チェック
for i in range(0, L-1):
    if S[i] == "#" and S[i+1] == "#":
        if i < C or i < D:
            print("No")
            exit()

# Bをこす必要があって越せないかチェック

if D < C:
    OK = False
    if S[B+1] == "." and S[B-1] == ".":
        print("Yes")
        exit()
    for i in range(0, L-2):
        if S[i] == "." and S[i+1] == "." and S[i+2] == ".":
            if B < i:
                print("Yes")
                exit()
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:

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

#jumpable
jumpable = 1
for i in range(A-1, D):
    if S[i]=="#":
        if S[i+1]=="#":
            jumpable = 0
            break;

#exchange
changable = 0
changeMax = min(D+1, N)

for i in range(B-1, changeMax-2):
    if S[i]==".":
        if S[i+1]==".":
            if S[i+2]==".":
                changable=1
                break

#飛び越えるあり
if(D<C):
    if(changable==0):
        jumpable=0

if(jumpable==0):
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
road = input()
if "##" in road[a-1:c-1] or "##" in road[b-1:d-1]:
  print("No")
else:
  if c < d:
    print("Yes")
  else:
    if "..." in road[b-2:c]:
      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[b+1:d]:
    print('No')
    exit()
if '##' in s[a+1:c]:
    print('No')
    exit()

if d < c:
    if '...' not in s[b-1:d+2]:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
    n,a,b,c,d =  [int(x) for x in input().split()]
    stage = input().rstrip()

    if '##' in stage:
        print('No') 
    elif d < c and not '...' in stage[b:d]:
        print('No')
    else:
        print('Yes')

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

fin = sys.stdin.readline
N, A, B, C, D = [int(elem) for elem in fin().split()]
cell_list = fin().split()[0]

need_swap = False
can_swap = False

# 途中に#が2つ連続しないか
if '##' in cell_list:
    result = 'No'
# 入れ替えが必要かどうか
elif (A-B) * (C-D) < 0:
    need_swap = True
    # 途中に.が3つ連続するかどうか（≒入れ替えが可能かどうか）
    if '...' in cell_list:
        can_swap = True
        result = 'Yes'
    else:
        result = 'No'
else:
    result = 'Yes'

print(result)

Submission status: Wrong Answer

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

if c<d:
    if '##' in s:
        print('No')
    else:
        print('Yes')
else:
    if a>b:
        if '##' in s:
            print('No')
        else:
            print('Yes')
    else:
        if b-1<0:
            print('No')
        else:
            if '...' in s[b-1:c]:
                print('Yes')
            else:
                print('No')

Submission status: Wrong Answer

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


def main():
  _, s_s, f_s, s_e, f_e = map(int, input().split())
  n = input().strip()

  if s_e == f_e:
    print('No')
  elif '##' in n[s_s:max(s_e, f_e)]:
    print('No')
  elif s_e < f_e:
    print('Yes')
  elif '...' in n[f_s - 1:f_e + 2]:
    print('Yes')
  else:
    print('No')


if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n,a,b,c,d = LI()
    s = input()
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    if c == d:
        print("No")
    else:
        if c < d:
            k = s[b:d+1]
            for i in range(d-b):
                if k[i] == k[i+1] == "#":
                    print("No")
                    quit()
            k = s[a:c+1]
            for i in range(c-a):
                if k[i] == k[i+1] == "#":
                    print("No")
                    quit()
            print("Yes")
        else:
            k = s[b:d+1]
            for i in range(d-b):
                if k[i] == k[i+1] == "#":
                    print("No")
                    quit()
            k = s[a:c+1]
            for i in range(c-a):
                if k[i] == k[i+1] == "#":
                    print("No")
                    quit()
            k = s[b:d+1]
            for i in range(d-b-1):
                if k[i] == k[i+1] == k[i+2] == ".":
                    print("Yes")
                    quit()
            print("No")
    return

#B
def B():
    s = S()

    return

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    A()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N, A, B, C, D = LI()
    S = SI()
    ans = True
    # AC
    for i in range(A, C):
        if S[i: i + 2] == '##':
            ans = False
            break
    # BD
    if ans:
        for i in range(B, D):
            if S[i: i + 2] == '##':
                ans = False
                break
    # if A BD C
    if ans and A < B < D < C:
        tmp = False
        for i in range(B - 1, D):
            if S[i: i + 3] == '...':
                tmp = True
                break
        ans = ans and tmp

    ans = 'Yes' if ans else 'No'
    return ans

print(main())

Submission status: Wrong Answer

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

if '##' in S[a:c + 1]:
    print('No')
elif '##' in S[b:d + 1]:
    print('No')
else:
    if c < d:
        print('Yes')
    elif '...' in S[b - 1:d + 1]:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

flag = False
r_count = [len(s) for s in S.split('.') if len(s) > 1]
if r_count != []:
    print('No')
    exit()
if C < D:
    print('Yes')
    exit()

count = [len(s) for s in S.split('#') if len(s) > 2]
print('Yes' if len(count) > 0 else 'No')

Submission status: Wrong Answer

Solution code:
n , a0 , b0 , c0 , d0 = map(int,input().split())
s = input()

# a < b に変換する
if a0 > b0 : # 入れ替える
    a = b0
    b = a0
    c = d0
    d = c0
else : # 入れ替えない
    a = a0
    b = b0
    c = c0
    d = d0

right = max(c,d)

for i in range(n-1) :
    if s[i] == '#' and s[i+1] == '#' : # 岩が2個連続である場合
        if i <= right :
            print('No')
            break
else :
    if c < d :
        print('Yes')
    else :
        for i in range(n-2) :
            if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.' : # 入れ替え可能
                if i < d :
                    print('Yes')
                    break
        else :
            print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = [int(i) for i in input().split()]
S = list(input())

gyaku = 0
if C > D:
    gyaku = 1

flag = 0
renzoku = 0
irekae = 0
for i in range(N):
    if S[i] == '#':
        renzoku = 0
        if flag == 1:
            if i < C-1 or i < D-1:
                print('No')
                exit()
        flag = 1

    else:
        flag = 0
        renzoku += 1
        if renzoku == 3:
            irekae = 1

    if gyaku:
        if i == D-1:
            if S[i-1] == '#':
                if irekae == 0:
                    print('No')
                    exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    n, a, b, c, d = get_li()
    s = get_str()
    if "##" in s[a:c]:
        print("No")
        return
    if "##" in s[b:d]:
        print("No")
        return
    if c > d and ("..." not in s[b:d] or (s[b:b+2] != ".." and s[d-2:d+1] != "...")):
        print("No")
        return
    print("Yes")
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int,input().split())
st = input()
if C == D :
  print("No")
elif C < D:#連続で岩が置かれていなければおっけー
  flag = 0
  st1 = st[A:C+1]
  for i in range(len(st1)-1):
    if st1[1:i+2] == "##":
      flag = 1
      
  st1 = st[B:D+1]
  for i in range(len(st1)-1):
    if st1[i:i+2] == "##":
      flag = 1
  if flag :
    print("No")
  else:
    print("Yes")
    
else:#入れ替わりを行う必要がある
  flag = 0
  irekaeble = 0
  st1 = st[A:C+1]
  for i in range(len(st1)-1):
    if st1[i:i+2] == "##":
      flag = 1
      
  st1 = st[B:D+1]
  for i in range(len(st1)-1):
    if st1[i:i+2] == "##":
      flag = 1
      
  st1 = st[B-1:C+1]
  for i in range(len(st)-2):
    if st1[i:i+3] == "...":
      irekaeble = 1
  
  if flag or irekaeble == 0:
    print("No")
  else:
    print("Yes")

Submission status: Wrong Answer

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

res = 'Yes'
# case 1
if C < D:
    for i in range(A-1, C-1):
        if S[i] == '#' and S[i+1] == '#':
            res = 'No'
    for i in range(B-1, D-1):
        if S[i] == '#' and S[i+1] == '#':
            res = 'No'
elif C == D:
    res = 'No'
else:
    cnt = 0
    for i in range(B-1, D-2):
        if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
            cnt += 1
    if cnt == 0:
        res = 'No'
    for i in range(A-1, C-1):
        if S[i] == '#' and S[i+1] == '#':
            res = 'No'

print(res)

Submission status: Wrong Answer

Solution code:
import sys
n, a, b, c, d = map(int,input().split())
s = input()
judgesharp = False
judgepass = False
threepoint = 0
if c < d:
  for i in s:
    if i == "#":
      if judgesharp == True:
        print("No")
        sys.exit()
      else:
        judgesharp = True
    else:
      judgesharp = False
  print("Yes")
else:
  for i in s:
    if i == "#":
      threepoint = 0
      if judgesharp == True:
        print("No")
        sys.exit()
      else:
        judgesharp = True
    else:
      threepoint += 1
      judgesharp = False
    if threepoint == 3:
      judgepass = True
  if judgepass:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

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


def main():
  _, s_s, f_s, s_e, f_e = map(int, input().split())
  n = input().strip()

  if s_e == f_e:
    print('NO')
  elif '##' in n[s_s:max(s_e, f_e)]:
    print('NO')
  elif s_e < f_e:
    print('YES')
  elif '...' in n[f_s - 1:f_e + 2]:
    print('YES')
  else:
    print('NO')


if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int, input().split())
S = input()[:min(c,d)]
if "##" in S:
  print('No')
elif c > d and "..." not in S:
  print('No')
else:
  print("Yes")

Submission status: Wrong Answer

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

tmp = 0
for i in range(A-1, C):
    if S[i] == "#":
        tmp += 1
    if S[i] == ".":
        tmp = 0
    if tmp == 2:
        print("No")
        sys.exit()

tmp = 0
for i in range(B-1, D):
    if S[i] == "#":
        tmp += 1
    if S[i] == ".":
        tmp = 0
    if tmp == 2:
        print("No")
        sys.exit()


tmp = 0
if C < D:
    print("Yes")
else:
    for i in range(B-1, D):
        if S[i] == ".":
            tmp += 1
        if S[i] == "#":
            tmp = 0
        if tmp == 3:
            print("Yes")
            sys.exit()
    print("No")

Submission status: Wrong Answer

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

if not '##' in S:
    if D<C:
        if '...' in S:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

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

if C > D:
    if '...' not in S:
        print("No")
        quit()

print("Yes")

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:


def main():
    n, a, b, c, d = map(int, raw_input().split())
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    s = raw_input()
    ok = False
    while b < d:
        if s[b - 1] == '.' and s[b + 1] == '.':
            ok = True
        if s[b + 1] == '.':
            b += 1
        elif b + 2 < n and s[b + 2] == '.':
            b += 2
        else:
            break
    if b != d:
        print 'No'
        return
    while a < c:
        if s[a + 1] == '.':
            a += 1
        elif a + 2 < n and s[a + 2] == '.':
            a += 2
        else:
            break
    if a != c:
        print 'No'
    elif c < d or ok:
        print 'Yes'
    else:
        print 'No'


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000)

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

n,a,b,c,d=intinput()
s=input()
if c<d:
    try:
        s.index("##")
    except:
        print("Yes")
        sys.exit()
    else:
        print("No")
        sys.exit()
else:
    try:
        s.index("...")
    except:
        print("No")
        sys.exit()
    else:
        print("Yes")
        sys.exit()

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int,input().split())
st = input()
if C == D :
  print("NO")
elif C < D:#連続で岩が置かれていなければおっけー
  flag = 0
  st1 = st[A:C+1]
  for i in range(len(st1)-1):
    if st1[1:i+2] == "##":
      flag = 1
      
  st1 = st[B:D+1]
  for i in range(len(st1)-1):
    if st1[i:i+2] == "##":
      flag = 1
  if flag :
    print("NO")
  else:
    print("YES")
    
else:#入れ替わりを行う必要がある
  flag = 0
  irekaeble = 0
  st1 = st[A:C+1]
  for i in range(len(st1)-1):
    if st1[i:i+2] == "##":
      flag = 1
      
  st1 = st[B:D+1]
  for i in range(len(st1)-1):
    if st1[i:i+2] == "##":
      flag = 1
      
  st1 = st[B-1:C+1]
  for i in range(len(st)-2):
    if st1[i:i+3] == "...":
      irekaeble = 1
  
  if flag or irekaeble == 0:
    print("NO")
  else:
    print("YES")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
road = input()
if "##" in road[a-1:c-1] or "##" in road[b-1:d-1]:
  print("NO")
else:
  if c < d:
    print("YES")
  else:
    if "..." in road[b-2:c]:
      print("YES")
    else:print("NO")

Submission status: Wrong Answer

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

# check no '##' s on the way
goal = max([c,d])
for x in range(a+1, goal):
  if s[x] == '#' and s[x+1] == '#':
    print('No')
    exit(0)

if c < d:
  print('Yes')
  exit(0)

for x in range(b, c):
  if s[x] == '.' and s[x+1] == '.' and s[x-1] == '.':
    print('Yes')
    exit(0)

print('No')

Submission status: Wrong Answer

Solution code:

def main():
    buf = input()
    buflist = buf.split()
    N = int(buflist[0])
    A = int(buflist[1])-1
    B = int(buflist[2])-1
    C = int(buflist[3])-1
    D = int(buflist[4])-1
    buf = input()
    S = buf
    if D < C:
        space = 0
        for i in range(B-1, min(C+2, N)):
            if S[i] == '.':
                space += 1
                if space >= 3:
                    break
            else:
                space = 0
        if space < 3:
            print('No') # unswappable
            return
    rock_count = 0
    for i in range(A, max(C, D)+1):
        if S[i] == '#':
            rock_count += 1
            if rock_count >= 2:
                break
        else:
            rock_count = 0
    if rock_count >= 2:
        print('No')
    else:
        print('Yes')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

ans = "Yes"
cnt = 0
tmp = 0
for i in range(A - 1, max(C, D)):
  if i != 0 and S[i] == "#" and S[i - 1] == "#":
    ans = "No"
    break
  if S[i] == ".":
    tmp += 1
  else:
    cnt = max(cnt, tmp)
    tmp = 0
cnt = max(cnt, tmp)
if D < C and cnt < 3:
  ans = "No"
print(ans)

Submission status: Wrong Answer

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

res = 'Yes'
# case 1
if C < D:
    for i in range(A-1, C-1):
        if S[i] == '#' and S[i+1] == '#':
            res = 'No'
    for i in range(B-1, D-1):
        if S[i] == '#' and S[i+1] == '#':
            res = 'No'
elif C == D:
    res = 'No'
else:
    cnt = 0
    for i in range(A-1, C-2):
        if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
            cnt += 1
    if cnt == 0:
        res = 'No'
    for i in range(A-1, C-1):
        if S[i] == '#' and S[i+1] == '#':
            res = 'No'

print(res)

Submission status: Wrong Answer

Solution code:
from sys import exit, setrecursionlimit, stderr, stdin
from functools import reduce
from itertools import *
from collections import defaultdict, Counter
from bisect import bisect
import functools

setrecursionlimit(10**7)

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

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N, A, B, C, D = reads()
S = input()

def reachable(i, j):
  return not any(S[k] == S[k+1] == "#" for k in range(i, j))

def swappable(i, j):
  return any(S[k] == S[k+1] == S[k+2] == "." for k in range(i, j-1))

A, B, C, D = A-1, B-1, C-1, D-1

possible = reachable(A, C) and reachable(B, D)

if D < C:
  possible = possible and swappable(B, D)

print("Yes" if possible else "No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int,input().split())
s = input()
check = False
if c < d:
    if "##" not in s:
        check = True
else:
    if "..." in s[b-1:c+1]:
        check = True
if check == True:
    print("Yes")
else:
    print("No")

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()
if "##" in s:
    print("No")
elif c < d:
    print("Yes")
elif s[d-1] == "#" or s[d+1] == "#":
    if "..." in s:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
n, a, b, c, d = map(int, input().split())
s = input()
snuke, fnuke, gnuke = 0, 0, 0
s_max, f_max, g_max = 0, 0, 0
for i in range(a-1, c):
	if s[i] == "#":
		snuke += 1
		s_max = max(s_max, snuke)
	else:
		snuke = 0
for i in range(b-1, d):
	if s[i] == "#":
		fnuke += 1
		f_max = max(f_max, fnuke)
		gnuke = 0
	else:
		fnuke = 0
		gnuke += 1
		g_max = max(g_max, gnuke)
if c>d:
	for i in range(b-2, d+1):
		if s[i] == ".":
			gnuke += 1
			g_max = max(g_max, gnuke)
		else:
			gnuke = 0

if s_max > 1 or f_max > 1:
	print("No")
elif c < d:
	print("Yes")
else:
	if g_max >= 3:
		print("Yes")
	else:
		print("No")

Submission status: Wrong Answer

Solution code:
import sys, math, collections, heapq, itertools
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0: a, b = b, a % b
    return b
  
def solve():
    N, A, B, C, D = map(int, input().split())
    S = input()
    Able = False
    if C < D:
        for i in range(A-1, C-1):
            if S[i] == S[i+1] == "#":
                break
        else:
            for i in range(B-1, D-1):
                if S[i] == S[i+1] == "#":
                    break
            else: Able = True
    else:
        for i in range(A-1, C-1):
            if S[i] == S[i+1] == "#":
                break
        else:
            for i in range(B-1, D-1):
                if S[i-1] == S[i] == S[i+1] ==".":
                    Able = True
                    break
    print("Yes" if Able else "No")



    INF = 10 ** 25
    mod = 7 + 10 ** 9
    return 0
  
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

if "##" in S[A:]:
  ans = "No"
elif C < D:
  ans = "Yes"
else:
  if "..." in S[A:]:
    ans = "Yes"
  else:
    ans = "No"

print(ans)

Submission status: Wrong Answer

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

if '##' in S[a:c + 1]:
    print('No')
elif '##' in S[b:d + 1]:
    print('No')
else:
    if c < d:
        print('Yes')
    elif '...' in S[b - 1:c + 1]:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)


def main():
    n,a,b,c,d = LI_()
    n += 1
    s = S()
    if d < c:
        f = 0
        for i in range(max(0,b-1), min(min(n-1,d+1), c-1)):
            if s[i:i+3] == '...':
                f = 1
                break
        if f == 0:
            return 'No'

    for i in range(a+1,c-1):
        if s[i:i+2] == '##':
            return 'No'
    for i in range(b+1,d-1):
        if s[i:i+2] == '##':
            return 'No'


    return 'Yes'


print(main())

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, A: int, B: int, C: int, D: int, S: str): 
    print(YES if(S[A-1:C].count('##') == 0 and S[B-1:D].count('##') == 0) else NO)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, A, B, C, D, S)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if S.count('##') > 0:
    print('No')
else:
    if C < D:
        print('Yes')
    else:
        if S.count('...') > 0:
            print('Yes')
        else:
            print('No')