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;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace AGC034A
{
    class Program
    {
        static void Solve()
        {
            var n = Input.NextInt();
            var a = Input.NextInt() - 1;
            var b = Input.NextInt() - 1;
            var c = Input.NextInt() - 1;
            var d = Input.NextInt() - 1;

            var s = Input.Next();

            bool goalable = false;
            if (c < d)
            {
                // A<B, C<Dを考える
                // AとBは完全に独立して考えられる
                goalable = reachable(s, b, d) && reachable(s, a, c);

            }
            else
            {
                // C>Dを考える
                // Bがゴールしたときの位置によってAのゴール可否が変わる
                // Bが石の隣で止まった
                // → この場合、Aがゴールできないので
                // Bはゴール以前で3マス以上連続した空きマスの真ん中で
                // 立ち止まることでAを先に行かせることができる
                if (reachable(s, b, d) && reachable(s, a, c))
                {
                    if (hasNearBlock(s, d))
                    {
                        if (has3Space(s, b, d))
                        {
                            goalable = true;
                        }
                    }
                    else
                    {
                        // dの周囲が空きマスなので、特に変わる点はない
                        goalable = true;
                    }
                }
            }

            Console.WriteLine(goalable ? "Yes" : "No");
        }

        private static bool reachable(string s, int start, int end)
        {
            // 後にいる方を先にゴールさせる
            // 2マス続けて石があったらだめ
            for (int i = start; i < end - 1; i++)
            {
                if (s[i] == '#' && s[i + 1] == '#')
                {
                    // 2マスを飛び越えられないので、クリアできない
                    return false;
                }
            }

            return true;
        }

        private static bool hasNearBlock(string s, int n)
        {
            if (n > 0) if (s[n - 1] == '#') return true;
            if (n < s.Length - 1) if (s[n + 1] == '#') return true;

            return false;
        }

        private static bool has3Space(string s, int start, int end)
        {
            for (int i = start; i < end - 2; i++)
            {
                if (s[i] != '#' && s[i + 1] != '#' && s[i + 2] != '#')
                {
                    // 3マス空きがあった
                    return true;
                }
            }

            return false;
        }

        #region Competitive Template
        public static void Main(string[] args)
        {
            var needsFlushOutput = true;
            if (needsFlushOutput)
            {
                // 細かく出力しないようにする
                var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
                Console.SetOut(sw);
            }

            // 仮想的に標準入力をセットする
            // NextLine系を使っていると使えない
            //Input.SetText("");

            Solve();

            Console.Out.Flush();
        }

        static class Input
        {
            static char[] separator = { ' ' };
            public static bool IsEof { get; set; }
            static Queue<string> q { get; set; }

            static Input()
            {
                IsEof = false;
                q = new Queue<string>();
            }

            /// <summary>
            /// 入力予約
            /// </summary>
            /// <param name="items"></param>
            public static void SetText(IEnumerable<string> items)
            {
                foreach (var item in items)
                {
                    SetText(item);
                }
            }

            /// <summary>
            /// 入力予約
            /// </summary>
            /// <param name="s"></param>
            /// <returns></returns>
            public static bool SetText(string s)
            {
                if (s == null) return false;

                foreach (var elem in s.Trim().Split(separator, StringSplitOptions.RemoveEmptyEntries))
                {
                    q.Enqueue(elem);
                }

                return true;
            }

            /// <summary>
            /// 内部queueに入力からの値をsplitして格納する
            /// </summary>
            /// <returns></returns>
            static bool read()
            {
                var s = Console.ReadLine();
                if (s == null) return false;

                foreach (var elem in s.Trim().Split(separator, StringSplitOptions.RemoveEmptyEntries))
                {
                    q.Enqueue(elem);
                }

                if (!q.Any()) return read();

                return true;
            }

            /// <summary>
            /// 次のstringを一つ読み込む
            /// </summary>
            /// <returns></returns>
            public static string Next()
            {
                if (!q.Any())
                {
                    if (!read())
                    {
                        IsEof = true;
                        return "";
                    }
                }

                return q.Dequeue();
            }

            public static int NextInt() => int.Parse(Next());
            public static long NextLong() => long.Parse(Next());
            public static double NextDouble() => double.Parse(Next());

            public static List<string> Next(int n) => Enumerable.Range(0, n).Select(_ => Next()).ToList();
            public static List<int> NextInt(int n) => Next(n).Select(x => int.Parse(x)).ToList();
            public static List<long> NextLong(int n) => Next(n).Select(x => long.Parse(x)).ToList();
            public static List<double> NextDouble(int n) => Next(n).Select(x => double.Parse(x)).ToList();

            public static List<string> NextLine() => Console.ReadLine().Trim().Split(separator, StringSplitOptions.RemoveEmptyEntries).ToList();
            public static List<int> NextIntLine() => NextLine().Select(x => int.Parse(x)).ToList();
            public static List<long> NextLongLine() => NextLine().Select(x => long.Parse(x)).ToList();
            public static List<double> NextDoubleLine() => NextLine().Select(x => double.Parse(x)).ToList();
        }
        #endregion
    }
}