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

建议使用的浏览器:

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

5741:Helter Skelter

题目描述
A non-empty string $s$ is called binary, if it consists only of characters "0" and "1". A substring $s[l \dots r]$ $(1 \le l \le r \le |s|)$ of string $s = s_{1}s_{2} \dots s_{|s|}$ (where $|s|$ is the length of string $s$) is string $s_{l}s_{l + 1}...s_{r}$.

Professor Zhang has got a long binary string $s$ starting with "0", and he wants to know whether there is a substring of the string $s$ that the occurrences of "0" and "1" in the substring is exact $a$ and $b$, respectively, where $a$ and $b$ are two given numbers.

Since the binary string is very long, we will compress it. The compression method is:
1. Split the string to runs of same characters.
2. Any two adjacent runs consist of different characters. Use the length of each run to represent the string.

For example, the runs of a binary string 00101100011110111101001111111 are {00, 1, 0, 11, 000, 1111, 0, 1111, 0, 1, 00, 1111111}, so it will be compressed into {2, 1, 1, 2, 3, 4, 1, 4, 1, 1, 2, 7}.
输入解释
There are multiple test cases. The first line of input contains an integer $T$, indicating the number of test cases. For each test case:

The first line contains two integers $n$ and $m$ $(1 \le n \le 1000, 1 \le m \le 5 \cdot 10^5)$ - the number of runs and the number of queries. The next line contains $n$ integers: $x_1, x_2, ..., x_n$ $(1 \le x_i \le 10^6)$, indicating the length of the each run.

Each of the following $m$ lines contains two integers $a_i$ and $b_i$ $(0 \le a_i, b_i \le |s|, 1 \le a_i + b_i \le |s|)$, which means Professor Zhang wants to know whether there is a substring of the string $s$ that the occurrences of "0" and "1" in the substring is exact $a_i$ and $b_i$.
输出解释
For each test case, a binary string of length $n$. The $i$-th number is "1" if the answer for the $i$-th query is yes, or "0" otherwise.
输入样例
3
2 3
3 4
3 0
3 4
1 2
3 4
1 2 3
5 1
4 2
1 3
3 2
12 10
2 1 1 2 3 4 1 4 1 1 2 7
2 1
2 2
2 3
2 4
2 5
4 1
4 2
4 3
4 4
4 5
输出样例
111
0101
1111101111
来自杭电HDUOJ的附加信息
Author zimpha
Recommend wange2014

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

源链接: HDU-5741

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

共提交 0

通过率 --%
时间上限 内存上限
10000/5000MS(Java/Others) 131072/131072K(Java/Others)