CF620F.Xors on Segments
省选/NOI-
通过率:0%
时间限制:10.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an array with n integers a__i and m queries. Each query is described by two integers (l__j, r__j).
Let's define the function
. The function is defined for only u ≤ v.
For each query print the maximal value of the function f(a__x, a__y) over all l__j ≤ x, y ≤ r__j, a__x ≤ a__y.
给你一个包含 n 个整数 ai 的数组,以及 m 个查询。每个查询由两个整数 (lj,rj) 描述。
我们定义函数
。
该函数仅对满足 u ≤ v 的参数有定义。
对于每个查询,请输出所有满足 lj ≤ x,y ≤ rj 且 ax ≤ ay 的 (x,y) 对所对应的函数值 f(ax,ay) 的最大值。
输入格式
The first line contains two integers n, m (1 ≤ n ≤ 5·104, 1 ≤ m ≤ 5·103) — the size of the array and the number of the queries.
The second line contains n integers a__i (1 ≤ a__i ≤ 106) — the elements of the array a.
Each of the next m lines contains two integers l__j, r__j (1 ≤ l__j ≤ r__j ≤ n) – the parameters of the j-th query.
第一行包含两个整数 n 和 m(1≤n≤5⋅104,1≤m≤5⋅103)—— 分别表示数组的大小和查询次数。
第二行包含 n 个整数 ai(1≤ai≤106)—— 表示数组 a 的元素。
接下来的 m 行中,每行包含两个整数 lj、rj(1≤lj≤rj≤n)—— 表示第 j 个查询的参数。
输出格式
For each query print the value a__j on a separate line — the maximal value of the function f(a__x, a__y) over all l__j ≤ x, y ≤ r__j, a__x ≤ a__y.
对于每个查询,在单独一行中输出值 aj——即在所有满足 lj≤x,y≤rj 且 ax≤ay 的 (x,y) 上,函数 f(ax,ay) 的最大值。
输入输出样例
输入#1
6 3 1 2 3 4 5 6 1 6 2 5 3 4
输出#1
7 7 7
输入#2
1 1 1 1 1
输出#2
1
输入#3
6 20 10 21312 2314 214 1 322 1 1 1 2 1 3 1 4 1 5 1 6 2 2 2 3 2 4 2 5 2 6 3 4 3 5 3 6 4 4 4 5 4 6 5 5 5 6 6 6
输出#3
10 21313 21313 21313 21313 21313 21312 21313 21313 21313 21313 2314 2315 2315 214 215 323 1 323 322
输入解题思路,AI测评打分。不知道怎么写?