QOJ.ac

QOJ

Time Limit: 2.22 s Memory Limit: 512 MB Total points: 100

#11284. Marchen

Statistics

给你一个 $1\dots n$ 的排列 $a$,共有 $q$ 次询问,每次询问给你一个区间 $[l,r]$,求满足 $l\le i < j < k\le r$ 且 $a_i< a_j< a_k$ 的三元组 $(i,j,k)$ 数量。

输入格式

本题强制在线。

第一行两个整数 $n,q$。

第二行 $n$ 个整数 $a_{1\dots n}$。

接下来 $q$ 行,每行两个整数 $l',r'$ 表示询问。你需要将 $l',r'$ 分别异或上次询问的答案得到真实的 $l,r$。特别地,如果这是第一次询问则 $l=l',r=r'$。

输出格式

$q$ 行,每行一个整数表示答案。

样例数据

样例 1 输入

5 7
2 3 4 5 1
3 3
1 3
0 4
6 1
0 4
7 0
1 2

样例 1 输出

0
1
4
1
4
0
0

样例2 输入

12 10
4 1 12 6 2 11 5 3 7 9 8 10
8 11
4 14
15 7
12 13
2 7
10 8
4 10
15 0
7 12
14 11

样例 2 输出

2
12
14
0
3
0
8
0
12
3

样例 3 输入

20 20
7 13 5 9 12 15 10 19 3 2 6 17 20 16 4 8 18 1 11 14
9 15
8 7
93 93
3 9
29 25
12 13
7 18
24 13
13 11
0 19
140 141
8 13
3 10
18 14
8 16
30 21
20 25
11 16
13 12
11 16

样例 3 输出

9
92
0
13
2
0
31
31
1
142
0
7
28
1
27
19
0
1
0
1

子任务

Idea:critnos,Solution:critnos,Code:critnos,Data:critnos

所有数据保证 $1\le n,q\le 10^5$,$1\le l\le r\le n$,$a$ 是一个 $1\dots n$ 的排列。

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.