PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#PS0000288. Trò chơi nhảy VII (Jump Game VII)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Trò chơi nhảy VII (Jump Game VII)

Jump Game VII

Source: LeetCode

Version: Phuoc Hung OJ Extended

Problem Statement

A binary string ss of length nn is indexed from 0 to n−1n-1, with s0=0s_0=0. Starting at index 0, a jump from ii to jj is allowed when i+L≤j≤min⁡(i+R,n−1)i+L\le j\le\min(i+R,n-1) and sj=0s_j=0. Determine whether index n−1n-1 is reachable.

Input

First line: n,L,Rn,L,R. Second line: the string ss of exactly nn binary characters, without spaces.

Output

Print lowercase true if the final index is reachable, or false otherwise.

Subtasks

  • Subtask 1 (20 points): 2≤n≤302\le n\le30; 1≤L≤R<n1\le L\le R<n; s0=0s_0=0; si∈{0,1}s_i\in\{0,1\}.
  • Subtask 2 (30 points): 2≤n≤1000002\le n\le100000; 1≤L≤R<n1\le L\le R<n; s0=0s_0=0; si∈{0,1}s_i\in\{0,1\}; L=RL=R.
  • Subtask 3 (50 points): 2≤n≤1000002\le n\le100000; 1≤L≤R<n1\le L\le R<n; s0=0s_0=0; si∈{0,1}s_i\in\{0,1\}.

Example 1

Input

6 2 3
011010

Output

true

Explanation

The path 0→3→5 uses jumps of length 3 and 2.

Example 2

Input

8 2 3
01101110

Output

false

Explanation

From 0 only index 3 is reachable; both indices 5 and 6 are blocked.