Pondo Compare

View as PDF

Submit solution

Points: 100
Time limit: 5.0s
Memory limit: 977M

Author:
Problem type

Problem Statement

You are given a string s of length n as well as Q queries.

Each query will contain the following four integers as information: l_1, r_1, l_2, r_2 each of which is an integer between 1 and n. Pondo would like you to determine whether the substring s[l_1 ..r_1] \leq s[l_2 ..r_2] (both integers are inclusive).

Input Format

Your first line will contain two space-separated integers n and Q. Your next line will contain a string of length n representing s. Your next Q lines will each contain l_1, r_1, l_2 and r_2 space-separated, representing the integers for that query.

Output Format

You should output one line for each query. For each line output YES if s[l_1 ..r_1] \leq s[l_2 ..r_2] otherwise output NO.

Constraints

  • 1 \leq n, Q \leq 10^5 ## Sample Cases
Input 1
10 4
abcdfabcde
1 5 6 10
1 4 6 9
1 10 1 10
6 9 1 5
Output 1
NO
YES
YES
YES
Explanation 1

abcdf is not less than or equal to abcde abcd is less than or equal to abcd abcdfabcde is less than or equal to abcdfabcde abcd is less than or equal to abcdf


Comments

There are no comments at the moment.