#P17154. [ICPC 2017 Xi'an R] Acedia

    ID: 19432 远端评测题 30000ms 512MiB 尝试: 0 已通过: 0 显示难度省选/NOI− 上传者: 标签>2017莫队树状数组枚举扫描线ICPC西安

[ICPC 2017 Xi'an R] Acedia

Problem Description

You are given a sequence of nn numbers, the kk-th number is a[k]a[k].

You need to answer mm queries.

Each query is: for each kk from 11 to 1010, calculate the number of valid pairs (x,x+k1)(x, x+k-1) in range [l,r][l,r].

We call a pair (x,y)(x,y) valid when:

  1. For each ii from xx to yy, there exists at least one element in range [l,r][l,r] which is equal to ii.
  2. There is no element in range [l,r][l,r] which is equal to x1x-1 or y+1y+1.

Input Format

The input contains multiple test cases.

The first line contains a number TT (1T5)(1 \le T \le 5) denoting the number of test cases.

In each test case:

The first line contains two numbers n,mn, m. (1n,m1000000)(1 \le n,m \le 1000000).

Then one line contains nn numbers indicating a[1]a[n]a[1]\dots a[n]. (0a[i]2000000000)(0 \le a[i] \le 2000000000)

The following mm lines each contain two numbers l,rl, r denoting a query in range [l,r][l,r]. (1lrn)(1 \le l \le r \le n)

Output Format

For each query you need to output 1010 numbers. In order to reduce the amount of output, you just need to output each number mod 1010, without space.

For each test case, output mm lines. The kk-th line contains a string of length 1010 indicating the answers of the kk-th query.

1
5 5
1 2 4 5 6
1 5
1 2
3 4
3 5
4 5
0110000000
0100000000
0100000000
0010000000
0100000000