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

Solution in C# (Mono 4.6.2.0) (judge verdict: Wrong Answer)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;


namespace AtCoderWorkspace
{
    class Program
    {
        static void Main(string[] args)
        {
            var cin = new Scanner();
            var N = cin.nextInt();
            var Afrom = cin.nextInt();
            var Bfrom = cin.nextInt();
            var Ato = cin.nextInt();
            var Bto = cin.nextInt();
            var S = cin.next();

            char[] road = S.ToArray();
            const int rock = -9;
            const int walk = -1;
            int[] roadV = road.Select((c) => {
                if (c == '.')
                {
                    return walk;
                }
                else
                {
                    return rock;
                }
            }).ToArray();

            // より右にあるものからバックトラック
            Stack<int> stack1 = new Stack<int>();            
            Stack<int> stack2 = new Stack<int>();
            var goal1 = 0;
            var goal2 = 0;
            if (Afrom < Bfrom)
            {
                stack1.Push(Bfrom-1);
                stack2.Push(Afrom-1);
                goal1 = Bto-1;
                goal2 = Ato-1;
            }
            else
            {
                stack1.Push(Afrom - 1);
                stack2.Push(Bfrom - 1);
                goal1 = Ato-1;
                goal2 = Bto-1;

            }

            bool goal1flag = false;
            while (stack1.Count() > 0)
            {
                var now1 = stack1.Pop();

                if(now1 == goal1)
                {
                    goal1flag = true;
                    roadV[now1] = rock;
                    break;
                }

                if (now1 + 2 <= N - 1)
                {
                    if (roadV[now1 + 2] != rock)
                    {
                        stack1.Push(now1 + 2);
                    }
                }

                if (now1 + 1 <= N - 1)
                {
                    if (roadV[now1 + 1] != rock)
                    {
                        stack1.Push(now1 + 1);
                    }
                }
            }
            
            if(goal1flag == false)
            {
                // goalにたどり着けず。
                Console.WriteLine("No");
                Environment.Exit(0);
            }

            bool goal2flag = false;
            while (stack2.Count() > 0)
            {
                var now2 = stack2.Pop();

                if (now2 == goal2)
                {
                    goal2flag = true;
                    break;
                }

                if (now2 + 2 <= N - 1)
                {
                    if (roadV[now2 + 2] != rock)
                    {
                        stack2.Push(now2 + 2);
                    }
                }

                if (now2 + 1 <= N - 1)
                {
                    if (roadV[now2 + 1] != rock)
                    {
                        stack2.Push(now2 + 1);
                    }
                }
            }

            if (goal2flag == false)
            {
                // goalにたどり着けず。
                Console.WriteLine("No");
                Environment.Exit(0);
            }

            Console.WriteLine("Yes");
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
    public static class ListExtensions
    {

        public static T Dequeue<T>(this IList<T> self)
        {
            var result = self[0];
            self.RemoveAt(0);
            return result;
        }


        public static void Enqueue<T>(this IList<T> self, T item)
        {
            self.Add(item);
        }


        public static T Peek<T>(this IList<T> self)
        {
            return self[0];
        }
    }

}