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: Runtime Error

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
s = []
for i in range(N):
    if S[i] == '.':
        s.append(0)
    else:
        s.append(1)
if C < B and B < D: #ACBDの順番
    flag = 0
    for i in range(C - A):
        if s[A + i] == 1 and s[A + i + 1] == 1:
            flag = 1
            break
    if flag == 0:
        for i in range(D - B):
            if s[B + i] == 1 and s[B + i + 1] == 1:
                flag = 1
                break
    if flag == 1:
        print('No')
    else:
        print('Yes')
elif B < C and C < D: # ABCDの順番
    flag = 0
    for i in range(D - B):
        if s[B + i] == 1 and s[B + i + 1] == 1:
            flag = 1
            break
    if flag == 0:
        for i in range(D - A):
            if s[A + i] == 1 and s[A + i + 1] == 1:
                flag = 1
                break
    if flag == 1:
        print('No')
    else:
        print('Yes')
else: #ABDCの順番
    flag = 0
    for i in range(D - B + 1):
        if s[B + i - 1] == 0 and s[B + i] == 0 and s[B + i + 1] == 0:
            flag = 1
            break
    if flag == 1:
        for i in range(C - A):
            if s[A + i] == 1 and s[A + i + 1] == 1:
                flag = 0
                break
    if flag == 1:
        print('Yes')
    else:
        print('No')

Submission status: Runtime Error

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
s = []
for i in range(N):
    if S[i] == '.':
        s.append(0)
    else:
        s.append(1)
if C < B and B < D: #ACBDの順番
    flag = 0
    for i in range(C-A):
        if s[A + i] == 1 and s[A + i + 1] == 1:
            flag = 1
            break
    if flag == 0:
        for i in range(D-B):
            if s[B + i] == 1 and s[B + i + 1] == 1:
                flag = 1
                break
    if flag == 1:
        print('No')
    else:
        print('Yes')
elif B < C and C < D: # ABCDの順番
    flag = 0
    for i in range(D-B):
        if s[B + i] == 1 and s[B + i + 1] == 1:
            flag = 1
            break
    if flag == 0:
        for i in range(B-A):
            if s[A + i] == 1 and s[A + i + 1] == 1:
                flag = 1
                break
    if flag == 1:
        print('No')
    else:
        print('Yes')
else: #ABDCの順番
    flag1 = 0
    flag2 = 0
    for i in range(D - B + 1):
        if s[B + i - 1] == 0 and s[B + i] == 0 and s[B + i + 1] == 0:
            flag1 = 1
            break
    if flag1 == 1:
        for i in range(C - A):
            if s[A + i] == 1 and s[A + i + 1] == 1:
                flag2 = 1
                break
    if flag1 == 1 and flag2 == 0:
        print('Yes')
    else:
        print('No')

Submission status: Runtime Error

Solution code:
#bin/usr/env python3

n, a, b, c, d = map(int,input().split())
s = input()
s_li = []

for i in s:
    s_li.append(i)

last = c
reach = True

if last < d:
    last = d

if c < d:
    for i in range(a-1,last-1):
        if(s_li[i] == "#" and s_li[i+1] == "#"):
            reach = False
            break

elif d < c:
    for i in range(a-1,last-1):
        if(s_li[i] == "#" and s_li[i+1] == "#"):
            reach = False
            break
        reach = False

        if(s_li[i+2] == "." and s_li[i] == "." and s_li[i+1] == "."):
            reach = True
            break

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

Submission status: Runtime Error

Solution code:

def sai():
  n,a,b,c,d=map(int(input()))
  s=input()
  for i in range(min(a,b),max(c,d)):
    if s[i]=='#' and s[i+1]=='#':
      return("NO")
  if (a<b and c>d) or(c<a and d>c):
    for i in range(min(a,b),max(c,d)-1):
      if s[i]=='.' and s[i+1]=="." and s[i+2]=='.':
        return("YES")
  else:
    return("YES")
  return("NO")

print(sai())

Submission status: Runtime Error

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

canGo = {}

def checkCanGo(a, b):

    if a == C and b == D:
        return True

    if (a, b) in canGo:
        return canGo[(a, b)]

    ops = []
    if a != C and a + 1 < len(S) and S[a + 1] == '.' and a + 1 != b:
        ops.append(checkCanGo(a + 1, b))
    if a != C and a + 2 < len(S) and S[a + 2] == '.' and a + 2 != b:
        ops.append(checkCanGo(a + 2, b))
    if b != D and b + 1 < len(S) and S[b + 1] == '.' and b + 1 != a:
        ops.append(checkCanGo(a, b + 1))
    if b != D and b + 2 < len(S) and S[b + 2] == '.' and b + 2 != a:
        ops.append(checkCanGo(a, b + 2))

    r = any(ops)
    canGo[(a, b)] = r

    return r

r = checkCanGo(A, B)
if r:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:

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

s = input()

#すぬけ君のゴールがふぬけ君より右にある場合
if c > d:
  #ゴールより左かつふぬけ君の右に岩のない部分が3つ連続していれば、すぬけ君はふぬけ君を追い越すことができる
  if s[a:c].count("##") == 0 and s[b:d].count("##") == 0:
    if s[b-1:d+1].count("...") >= 1:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  s[a:c].count("##") == 0 and s[b:d].count("##") == 0:
    print("Yes")
  else:
    print("No")

Submission status: Runtime Error

Solution code:
n,a,b,c,d = map(int, input().split())
​
s = input()
​
​
#すぬけ君のゴールがふぬけ君より右にある場合
if c > d:
  #ゴールより左かつふぬけ君の右に岩のない部分が3つ連続していれば、すぬけ君はふぬけ君を追い越すことができる
  if s[a:].count("##") == 0:
    if s[b-1:d+1].count("...") >= 1:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  if s[a:].count("##") == 0:
    print("Yes")
  else:
    print("No")

Submission status: Runtime Error

Solution code:

#include <bits/stdc++.h>

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

string s;

void jump(const int i, const int j, VI& A)
{
    A[i] = 1;
    FOR(x,i,j) if (A[i]) {
        FOR(d,1,3) if (x+d <= j && s[x+d] != '#') {
            A[x+d] = 1;
        }
    }
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n,a,b,c,d; 
    while (cin >> n >> a >> b >> c >> d >> s) {
        s = ' ' + s;
        VI A(n+1), B(n+1);
        jump(a,c,A);
        jump(b,d,B);
        bool ans = A[c] && B[d];
        if (ans && c > d) {
            ans = false;
            FOR(i,1,n+1)
                ans |= A[i-1] && B[i] && A[i+1];
        }
        cout << (ans ? "Yes" : "No") << endl;
    }
    return 0;
}

Submission status: Runtime Error

Solution code:
n, a, b, c, d = input()
s = input()

if "##" in s:
  print("No")
elif c > d:
  if "..." in s:
    print("Yes")
  else:
    print("No")
else:
  print("Yes")

Submission status: Runtime Error

Solution code:
using namespace std;
 
int main() {
    int N, A, B, C, D;
    string S;
    cin >> N >> A >> B >> C >> D >> S;
    
    S = "#" + S + "#";
 
    auto can_reach = [&](int start, int end) {
        for (int i = start; i + 1 <= end; i++) {
            if (S[i] == '#' && S[i + 1] == '#') return false;
        }

Submission status: Runtime Error

Solution code:
n,a,b,c,d=map(int,input().split())
s=str(input())
s=s.replace('.','0')
s=s.replace('#','1')
x=0
y=0
f=0
g=0
for i in range(c-a-2):
    x=int(s[i+a+1])
    y=int(s[i+a+2])
    if(x*y==1):
        f=-1
for j in range(d-b-2):
    x=int(s[j+b+1])
    y=int(s[j+b+2])
    if(x*y==1):
        g=-1
if(d<c):
    if(s[b+1:d].find('000')==-1 and ):
        f=-1
if(f==0 and g==0):
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
n,a,b,c,d=map(int,input().split())
s=str(input())
s=s.replace('.','0')
s=s.replace('#','1')
x=0
y=0
f=0
g=0
for i in range(c-a-2):
    x=int(s[i+a+1])
    y=int(s[i+a+2])
    if(x*y==1):
        f=-1
for j in range(d-b-2):
    x=int(s[j+b+1])
    y=int(s[j+b+2])
    if(x*y==1):
        g=-1
x=s.replace('11','7')
x=x.replace('000','8')
x=x.replace('0','')
x=x.replace('1','')
if(d<c):
    if(s[b+1:d].find('000')==-1 and ):
        f=-1
if(f==0 and g==0):
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

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

if "##" in s[a:c+1] or "##" in s[b:d+1] :
  print("No")
elif c<d:
  print("Yes")
elif "..." in s[b-2:d] :#以下 d<c の場合
  print("Yes")
  else:
    print("No")

Submission status: Runtime Error

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

if "##" in s[a-1:c] or "##" in s[b-1:d] :
  print("No")
elif c<d:
  print("Yes")
elif "..." in s[b-2:b+3] :#以下 d<c の場合
  print("Yes")
  else:
    print("No")

Submission status: Runtime Error

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


while i<S.length:
    temp[i]=

Submission status: Runtime Error

Solution code:
ｎ

Submission status: Runtime Error

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

e = 'Yes'
f = 0
g = 0

if c<d:
    for i in range(a-1,c-1):
        if s[i]=='#' and s[i+1]=='#':
            e ='No'
        else:
            for j in range(b-1,d-1):
                if s[j]=='#' and s[j+1]=='#':
                    e ='No'
                        
if c>d:
    for i in range(a-1,d-1):
        if s[i]=='#' and s[i+1]=='#':
            f =1
    
    for j in range(a-1,d-2):
        if s[j]=='' and s[j+1]=='' and s[j+2]=='':
            g = 0
        else:
            g = 1
            
if g==1 or f==1:
    e ='No'

print(e)

Submission status: Runtime Error

Solution code:
def a_kenken_race(N, A, B, C, D, S):
    # cond1: 道のりの途中に岩が2つ連続する場所があると、ゴールに到達できない
    # cond2: ふぬけ君の道のりの途中に空きが3マス分ないと、すぬけ君が追い越せない
    cond1 = S[A:C + 1].count('##') == 0 and S[B:D + 1].count('##') == 0
    cond2 = S[B:D + 1].count('...') >= 1
    if C < D:
        # ふぬけ君をゴールに行かせてからすぬけ君をゴールに行かせればよい
        ans = 'Yes' if cond1 else 'No'
    else:
        # すぬけ君は途中でふぬけ君を追い越せないといけない
        ans = 'Yes' if cond1 and cond2 else 'No'
    return ans

S = input()
print(a_kenken_race(N, A, B, C, D, S))

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, a, b, c, d;
    cin>>n>>a>>b>>c>>d;
    string s;
    cin>>s;
    s = '#' + s + '#';
    bool con = false;
    for(int i = 0;i< n-1;i++){
        if(s[i] == '#' && s[i+1] == '#'){
            con = true;
        }
    }
    if(con == true){
        cout<<"No"<<endl;
    } else {
        if(c < d){
            cout<<"Yes"<<endl;
        } else {
            bool con3 = false;
            for (int i = b - 1; i <= d - 3; i++) {
                if(s[i] == '.' && s[i+1] == '.' && s[i+2] == '.'){
                    con3 = true;
                }
            }
            if(con3){
                cout<<"Yes"<<endl;
            } else {
                cout<<"No"<<endl;
            }
        }
    }
    return 0;
}

Submission status: Runtime Error

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

c1 = [0] * len(S)
c2 = [0] * len(S)
cnt1 = 0
cnt2 = 0
for i in range(len(S)):
    if '.' == S[i]:
        c2[i] = cnt2
        cnt2 = 0
        cnt1 += 1
    else:
        c1[i] = cnt1
        cnt1 = 0
        cnt2 += 1

c1[-1] = cnt1
c2[-1] = cnt2

index2 = []
index1 = []
for i in range(N):
    if c2[i] >= 2:
        index2.append(i)
    if c1[i] >= 3:
        index1.append(i)

flag = True
for i in index2:
    if A < i - c2[i] + 1 < C or B < i - c2[i] + 1 < D:
        flag = False

if C > D and flag:
    flag = False
    for i in index1:
        if B < i < D:
            if D == i - cnt1[i] + 1:
                flag = False
                break
            flag = True

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

Submission status: Runtime Error

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

AtoC = True
BtoD = True
replace = False

for n in list(range(A-1,C)):
    if S[n] =='#' and S[n+1] =='#':
        AtoC = False
        
for n in list(range(B-1,D)):
    if S[n] =='#' and S[n+1] == '#':
        BtoD = False
        
for n in list(range(B-2,D-1)):
    if S[n] =='.' and S[n+1] == '.' and S[n+2] == '.':
        replace = True
if C<D:
    if AtoC == True and BtoD == True:
        print('Yes')
    else:
        print('No')
else:
    if AtoC == True and BtoD == True and replace == True:
        print('Yes')
    else:
        print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

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

    
    elif c>d:
        if  i>=b-1 and i<d+1 and s[i]=='.' and  s[i+1]=='.' and s[i+2]=='.' :
            x=1
            break
if x==0 and c>d:
    print('No')
            
if x==1:
    for i in range(n-2):
        if i>b and i<c and s[i]=='#' and s[i+1]=='#':
            print('No')
            v+=1
            break
    if v==0 and x==1:
        print('Yes')
if c<d and v==0:
    print('Yes')

Submission status: Runtime Error

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 = input()

    ans = 'Yes'
    if '##' in S[A-1:C] or '##' in S[B-1:D]:
        ans = 'No'

    if D < C:  # 追い越す場所が必要
        if '...' not in S[B-3:D+1]:
            ans = 'No'

    print(ans)


if __name__ == '__main__':
    main()
v

Submission status: Runtime Error

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

b_to_d = s[b - 1:d]
a_to_last = s[a - 1:max(c, d)]

if '##' in a_to_last:
    print('No')
    exit()

if c > d and '...' not in b_to_d:
    print('No')
    exit()

if s[c] == '#' or s[d] == '#':
    print('No')
    exit()

print('Yes')

Submission status: Runtime Error

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):
        if S[s] == '.':
            if blocks > 1:
                print('No')
                exit()
            blocks = 0
        else:
            blocks += 1

    blocks = 0
    for s in range(B - 1, D):
        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: Runtime Error

Solution code:
judge = True
if "##" in s[a - 1:c] or "##" in s[b - 1:d]:
    judge = False

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

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

Submission status: Runtime Error

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()

	for i in range(B-1,D):
		if S[i]==S[i+1]==S[i+2]==".":
			print "Yes"
			quit()

	print "No"

Submission status: Runtime Error

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")
	e;se:
      print("No")

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

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

BLOCK=[0]*N
OPEN=[0]*N

for i in range(1,N):
    if S[i]=="#" and S[i-1]=="#":
        BLOCK[i]=1

for i in range(2,N):
    if S[i]==S[i-1]==S[i-2]==".":
        OPEN[i]=1

RIGHT_A=N-1
for i in range(A,N):
    if BLOCK[i]==1:
        RIGHT_A=i
        break

RIGHT_B=N-1
for i in range(B,N):
    if BLOCK[i]==1:
        RIGHT_B=i
        break

if C<=RIGHT_A+1 and D<=RIGHT_B+1:
    if C<D:
        print("Yes")
    if RIGHT_A==RIGHT_B:
        for j in range(B+1,D+3):
            if OPEN[j]==1:
                print("Yes")
                sys.exit()

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

Submission status: Runtime Error

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

A, B, C, D = A - 1, B - 1, C - 1, D - 1
if (A < C < B < D) or (A < B < C < D):
    for i in range(A, C + 1):
        if S[i] == '#' and S[i + 1] == '#':
            print('No')
            exit()
    for i in range(B, D + 1):
        if S[i] == '#' and S[i + 1] == '#':
            print('No')
            exit()
    print('Yes')
    exit()

if A < B < D < C:
    for i in range(A, C + 1):
        if S[i] == '#' and S[i + 1] == '#':
            print('No')
            exit()

    for i in range(B, D + 1):
        if S[i] == '#' and S[i + 1] == '#':
            print('No')
            exit()

    for i in range(B + 1, D + 1):
        if S[i] == '.' and S[i + 1] == '.' and S[i + 2] == '.':
            print('Yes')
            exit()
    print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
n,a,b,c,d=map(int,input().split());s=input();t=[b-2:d+1];print('YNeos'[not'...'*(d<c)in t or'##'in s[a:c]+t::2])

Submission status: Runtime Error

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

def check_serial(mark, number, start, end):
    ans = False
    i = start
    while i < end:
        for j in range(number):
            if j+i > end:
                break
            if s[i+j] != mark:
                i += j 
                break
            elif j == number-1:
                ans = True
        if ans:
            break
        i += 1
    return ans

# print(check_serial('.', 3, 0, n-1))
ans = True
if c > d:
    ans = check_serial('.', 3, b-1, d+1)
if check_serial('#', 2, a, c-1):
    ans = False
if ans:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
f=0;F=0
for i in range(a,max(c,d)-1):
  if s[i]=='#' and s[i+1]=='#':f=1
for i in range(b-2,d-1):
  if s[i]=='.' and s[i+1]=='.' and s[i+2]=='.':F=1
if F==0 and c>d:f=1
print('YNeos'[f::2])

Submission status: Runtime Error

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

def check_serial(mark, number, start, end):
    ans = False
    i = start
    while i < end:
        for j in range(number):
            if j+i > end:
                break
            if s[i+j] != mark:
                i += j 
                break
            elif j == number-1:
                ans = True
        if ans:
            break
        i += 1
    return ans

# print(check_serial('.', 3, 0, n-1))
ans = True
if c > d:
    ans = check_serial('.', 3, b-1, d+2)
if check_serial('#', 2, a, c-1):
    ans = False
if ans:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
figure=input()
math=input()
flg=False
 
figure=figure.split(' ')
if math[3]>math[4]:
  flg=True
  
for i in range(len(math)-1):
  if math[i]=='#' and math[i+1]=='#':
    print('No')
    exit()
    
  if flg and i>=int(figure[2])-1 and i<int(figure[4])-1 and math[i]=='.' and math[i+1]=='.' and math[i+2]=='.':
    flg=False

if not flg:
	print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
N,A,B,C,D = map(int, input().split())
s = input()
index = [(n+1) for n, v in enumerate(s) if s[n:n+3] == "..."]

if "##" in s[a:]:
    print("No")

else:
    if C < D:
        print("Yes")

    if C > D:
        if len(index)>=1:
            for i in index:
                if B <= i+1 <= D:
                    print("Yes")
                    exit()
            print("No")
        else:
            print("No")

Submission status: Runtime Error

Solution code:
figure=input()
math=input()
flg=False
 
figure=figure.split(' ')
if math[3]>math[4]:
  flg=True
  
for i in range(len(math)-1):
  if math[i]=='#' and math[i+1]=='#':
    print('No')
    exit()
    
  if flg and i>=int(figure[2]-1) and i<int(figure[4])-1 and math[i]=='.' and math[i+1]=='.' and math[i+2]=='.':
    flg=False

if not flg:
	print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
figure=input()
math=input()
flg=False
 
figure=figure.split(' ')
if math[3]>math[4]:
  print('a')
  flg=True
  
for i in range(len(math)-1):
  if math[i]=='#' and math[i+1]=='#':
    print('No')
    exit()
    
  if flg and i<int(figure[4])-1 and math[i]=='.' and math[i+1]=='.' and math[i+2]=='.':
    flg=False

if not flg:
	print('Yes')
else:
  print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

n,a,b,c,d = map(int,input().split())
s = input()
s = s + "."
cant = 0
sanrenzoku = 0
for i in range(a-1,max(c-1,d-1)):
    if s[i] == "#":
        if s[i+1] == "#":
            cant = 1

if c > d:
    for i in range(b-2,d-1)
    if s[i] == ".":
        if s[i+1] == ".":
            if s[i+2] == ".":
                if i > b-2:
                    if i < d:
                        sanrenzoku = 1

if cant == 1:
    print("No")
elif c > d:
    if sanrenzoku == 0:
        print("No")
    else:
        print("Yes")
else:
    print("Yes")

Submission status: Runtime Error

Solution code:
import sys

N,A,B,C,D = map(int, input().split())
s = input()
#index = [(n+1) for n, v in enumerate(s) if s[n:n+3] == "..."]
#print(index)

if s.count("##")>=1:
    print("No")
    sys.exit()

if C < D:
    print("Yes")

elif C > D:
    if len(index)>=1:
        for i in index:
            if B <= i+1 <= D:
                print("Yes")
                sys.exit()
        print("No")
    else:
        print("No")

Submission status: Runtime Error

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

a_to_c = s[a:(c-1)-1]
b_to_d = s[b-1:d-1]

possibility = True

if c>d:
    b_to_d = s[(b-1)-1:(d-1)+1]
    if "##" in a_to_c or "..." not in b_to_d
        possibility = False
else:
    b_to_d = s[(b-1)+1:(d-1)-1]
    if "##" in a_to_c or "##" in b_to_d:
        possibility = False

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

Submission status: Runtime Error

Solution code:
import sys

N,A,B,C,D = map(int, input().split())
s = input()
#index = [(n+1) for n, v in enumerate(s) if s[n:n+3] == "..."]
#print(index)

if s.count("##")>=1:
    print("No")
    sys.exit(0)

if C < D:
    print("Yes")

elif C > D:
    if len(index)>=1:
        for i in index:
            if B <= i+1 <= D:
                print("Yes")
                sys.exit(0)
        print("No")
    else:
        print("No")

Submission status: Runtime Error

Solution code:
import sys

N,A,B,C,D = map(int, input().split())
s = input()
#index = [(n+1) for n, v in enumerate(s) if s[n:n+3] == "..."]
#print(index)

if s.count("##")>=1:
    print("No")
    sys.exit()

if C < D:
    print("Yes")

elif C > D:
    if len(index)>=1:
        for i in index:
            if B <= i+1 <= D:
                print("Yes")
                exit()
        print("No")
    else:
        print("No")

Submission status: Runtime Error

Solution code:
n,a,b,c,d = map(int,input().split())
s = input()
s = s + "."
cant = 0
sanrenzoku = 0
for i in range(a+1,d+1):
    if s[i] == "#":
        if s[i+1] == "#":
            cant = 1
    if c > d:
        if s[i] == ".":
            if s[i+1] == ".":
                if s[i+2] == ".":
                    if i > b-2:
                        if i < d:
                            sanrenzoku = 1

if cant == 1:
    print("No")
elif c > d:
    if sanrenzoku == 0:
        print("No")
    else:
        print("Yes")
else:
    print("Yes")

Submission status: Runtime Error

Solution code:
figure=input()
math=input()
flg=False

figure=figure.split(' ')
if math[3]>math[4]:
  flg=True
  
for i in range(len(math)-1):
  if math[i]=='#' and math[i+1]=='#':
    print('No')
    exit()
    
  if flg and i<figure[4] and math[i]=='.' and math[i]=='.' and math[i+2]=='.':
    flg=False

if not flg:
	print('Yes')

Submission status: Runtime Error

Solution code:
n,a,b,c,d = (int(i) for i in input().split())  
s = input()
e = 0
if c<d:
  if s[a:c-1].count("##")==0 and s[b:d-1].count("##")==0:
    print("Yes")
  else:
    print("No")
else:
  if s[a:c-1].count("##")==0 and s[b:d-1].count("##")==0 and s.[b-2:d+1].count("...")>0:
    print("Yes")
  else:
    print("No")

Submission status: Runtime Error

Solution code:
s = input()
e = 0
if c<d:
  if s[a:c-1].count("##")==0 and s[b:d-1].count("##")==0:
    print("Yes")
  else:
    print("No")
else:
  if s[a:c-1].count("##")==0 and s[b:d-1].count("##")==0 and s.[b-2:d+1].count("...")>0:
    print("Yes")
  else:
    print("No")

Submission status: Runtime Error

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

def check_serial(mark, number, start, end):
    ans = False
    i = start
    while i < end:
        for j in range(number):
            if s[i+j] != mark:
                i += j 
                break
            elif j == number-1:
                ans = True
        if ans:
            break
        i += 1
    return ans

ans = False
if c > d:
    ans = check_serial('.', 3, b, d)
ans = not check_serial('#', 2, a, c)
if ans:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

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

def check_serial(mark, number, start, end):
    ans = False
    i = start
    while i < end:
        for j in range(number):
            if s[i+j] != mark:
                i += j 
                break
            elif j == number-1:
                ans = True
        if ans:
            break
        i += 1
    return ans

ans = False
ans = not check_serial('#', 2, a, c)
if c > d:
    ans = check_serial('.', 3, b, d)
if ans:
    print('Yes')
else:
    print('No')