当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6539:Neko and sequence

题目描述
One day, Inu asked Neko a question:
Give you a sequence with $n$ elements. The index for the first element is $0$, the last is $n-1$.
They are arranged in rings. $0$ and $n-1$ are next to each other.
The $i$-th element has a character $s[i]$ which is '(' or ')'.
Let $f(i, d)$ means the last place to arrive by starting with $i$ and taking $d$ steps.
If you are in $i$-th element now and $s[i] = $'(', you will arrive $(i-k+n)\%n$-th element in next step, or you will arrive $(i+k)\%n$-th element.
And there are $q$ questions.Each question has three integers $l, r, d$. You have to calculate $\sum_{i = l}^{r} f(i,d)$
输入解释
The first line contains three integers $n, q, k(1 \leq n, q \leq 10^{5}, 1 \leq k < n)$ .
The second line contains a sequence, the $i$-th element means $s[i]$ .
The next $q$ line, each line contains three integers $l,r,d(0 \leq l \leq r < n, 1 \leq d \leq 10^{9})$ .
输出解释
For each question output the sum in one line.
输入样例
6 5 1
())()(
0 1 3
1 3 2
1 4 3
2 5 6
0 3 4
输出样例
7
8
12
14
12
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6539

最后修改于 2020-10-25T23:32:08+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 65536/65536K(Java/Others)