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.

给你一个包含 nn 个整数 aia_i 的数组,以及 mm 个查询。每个查询由两个整数 (lj, rj)(l_j,\,r_j) 描述。

我们定义函数
。
该函数仅对满足 u ≤ vu \leq v 的参数有定义。

对于每个查询,请输出所有满足 lj ≤ x, y ≤ rjl_j \leq x,\,y \leq r_j 且 ax ≤ aya_x \leq a_y 的 (x,y)(x, y) 对所对应的函数值 f(ax, ay)f(a_x,\,a_y) 的最大值。

输入格式

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.

第一行包含两个整数 nn 和 mm(1≤n≤5⋅1041 \leq n \leq 5\cdot10^4,1≤m≤5⋅1031 \leq m \leq 5\cdot10^3)—— 分别表示数组的大小和查询次数。

第二行包含 nn 个整数 aia_i(1≤ai≤1061 \leq a_i \leq 10^6)—— 表示数组 aa 的元素。

接下来的 mm 行中,每行包含两个整数 ljl_j、rjr_j(1≤lj≤rj≤n1 \leq l_j \leq r_j \leq n)—— 表示第 jj 个查询的参数。

输出格式

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.

对于每个查询,在单独一行中输出值 aja_j——即在所有满足 lj≤x,y≤rjl_j \le x, y \le r_j 且 ax≤aya_x \le a_y 的 (x,y)(x, y) 上,函数 f(ax,ay)f(a_x, a_y) 的最大值。

输入输出样例

  • 输入#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测评打分。不知道怎么写?

首页