QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 1024 MB Total points: 100

#9639. 字符串

الإحصائيات

题目背景

崩坏的句号

trade 100 string 0 book 0

好丢人啊

s t r i n g 0 s t r i n g 0 s t r i n g 0 s t r i n g 0 s t r i n g 0 s t r i

只剩最后一次机会

$R(s[i+l:i+2l-1])$ $R(s[i+l:i+2l-1])$ $R(s[i+l:i+2l-1])$ $R(s[i+l:i+2l-1])$ $R(s[i+l$ $R$ $R$ $R$ $R$ $r$ $r$ $r$ $r$

不能再浪费了

2023.7

题目描述

给定一个长度为 $n$ 的字符串 $s[1:n]$。有 $q$ 次询问,每次询问给定两个参数 $i, r$。你需要求出有多少 $l$,满足如下条件:

  • $1 \le l \le r$。
  • $s[i:i+l-1]$ 字典序小于 $s[i+l:i+2l-1]$ 。

输入格式

第一行包含一个整数 $c$,表示子任务编号。$c=0$ 表示该测试点为样例。

第二行包含两个正整数 $n, q$,表示字符串长度和询问次数。

第三行包含一个长度为 $n$ 的仅包含小写字母的字符串 $s$。

接下来 $q$ 行,每行包含两个正整数 $i, r$,表示一次询问,保证 $i + 2r - 1 \le n$。

输出格式

对于每一次询问,输出一行一个整数,表示满足条件的 $l$ 的个数。

样例

样例输入 1
0
9 3
abacababa
1 4
2 4
3 3
样例输出 1
3
1
2

数据范围

对于所有数据,$1 \le n, q \le 5 \times 10^5$,$1 \le i + 2r - 1 \le n$,字符串 $s$ 仅包含小写字母。

子任务编号 分值 特殊性质
$1$ $20$ $n, q \le 5 \times 10^3$
$2$ $10$ $n, q \le 10^5$ ,保证 $s$ 中每个字符在 $a, b$ 中随机生成
$3$ $20$ $n, q \le 10^5$
$4$ $20$ $n, q \le 3 \times 10^5$
$5$ $30$ 无特殊限制
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.