logo AlgoBeat OnlineJudge
登录 注册

#215291. [SWERC 2025] Expansion Plan 2

内存限制:1024 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

You are dealing with side quests in the video game Expansion Plan 2.

There is an infinite grid of bonus levels, with coordinates (specifically, the cell immediately above is , and the cell immediately on the right of is ). Initially, only the bonus level at is unlocked.

Given a string of length consisting of characters "4" and "8", you play times in a row; at the -th play you obtain a score equal to . For each from 1 to :

  • if : for each bonus level, if it is orthogonally adjacent (i.e., it shares a side) to a level which was already unlocked before the -th play, it becomes unlocked; otherwise, its state remains the same;
  • if : for each bonus level, if it is orthogonally or diagonally adjacent (i.e., it shares a side or a corner) to a level which was already unlocked before the -th play, it becomes unlocked; otherwise, its state remains the same.

You are given a string of length consisting of characters "4" and "8".

You have to answer queries. In each query, you start with an infinite grid where only the bonus level is unlocked, and you are given four integers . You have to determine whether the bonus level is unlocked after getting the scores in the substring of .

输入格式

The first line contains two integers () — the length of the string and the number of queries, respectively.

The second line contains a string of length consisting of characters "4" and "8".

Each of the next lines contains four integers (, ), representing a query on the substring and the bonus level .

输出格式

For each query, output YES if the bonus level is unlocked after getting the scores in the substring of , and NO otherwise.

The judge is case-insensitive (for example, YES, Yes, yes, yEs will all be recognized as positive answers).

样例

样例输入 1

10 6
4884884888
8 10 3 3
4 7 5 1
4 7 3 -3
1 7 -7 -5
1 10 0 0
1 1 1 1

样例输出 1

YES
NO
YES
NO
YES
NO

数据范围与提示

Explanation of sample 1.

The first three queries are illustrated below:

:::align{center} :::

In the first query, , and . The substring of is "888". After getting the scores in this substring, the bonus level is unlocked, so the answer is YES.

In the second query, the bonus level is not unlocked after getting the scores in the substring "4884".