CF1617E.Christmas Chocolates

省选/NOI-

通过率:0%

时间限制:4.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Christmas is coming, Icy has just received a box of chocolates from her grandparents! The box contains nn chocolates. The ii-th chocolate has a non-negative integer type aia_i.

Icy believes that good things come in pairs. Unfortunately, all types of chocolates are distinct (all aia_i are distinct). Icy wants to make at least one pair of chocolates the same type.

As a result, she asks her grandparents to perform some chocolate exchanges. Before performing any chocolate exchanges, Icy chooses two chocolates with indices xx and yy (1≤x,y≤n1 \le x, y \le n, x≠yx \ne y).

In a chocolate exchange, Icy's grandparents choose a non-negative integer kk, such that 2k≥ax2^k \ge a_x, and change the type of the chocolate xx from axa_x to 2k−ax2^k - a_x (that is, perform ax:=2k−axa_x := 2^k - a_x).

The chocolate exchanges will be stopped only when ax=aya_x = a_y. Note that other pairs of equal chocolate types do not stop the procedure.

Icy's grandparents are smart, so they would choose the sequence of chocolate exchanges that minimizes the number of exchanges needed. Since Icy likes causing trouble, she wants to maximize the minimum number of exchanges needed by choosing xx and yy appropriately. She wonders what is the optimal pair (x,y)(x, y) such that the minimum number of exchanges needed is maximized across all possible choices of (x,y)(x, y).

Since Icy is not good at math, she hopes that you can help her solve the problem.

圣诞节快到了,Icy 刚刚收到了祖父母送给她的一盒巧克力!盒子里共有 nn 块巧克力。第 ii 块巧克力的类型为一个非负整数 aia_i。

Icy 相信好事成双。但不幸的是,所有巧克力的类型互不相同(即所有 aia_i 互异)。Icy 希望至少使一对巧克力的类型变得相同。

因此,她请祖父母进行若干次巧克力交换操作。在执行任何交换操作前,Icy 先选定两个下标 xx 和 yy(满足 1≤x,y≤n1 \le x, y \le n 且 x≠yx \ne y)。

一次巧克力交换操作中,Icy 的祖父母选择一个非负整数 kk,使得 2k≥ax2^k \ge a_x,并将第 xx 块巧克力的类型由 axa_x 改为 2k−ax2^k - a_x(即执行赋值操作 ax:=2k−axa_x := 2^k - a_x)。

该交换过程仅在 ax=aya_x = a_y 时停止。注意:其他任意一对相等的巧克力类型并不会导致过程停止。

Icy 的祖父母非常聪明,因此他们总会选择使所需交换次数最少的操作序列。而 Icy 喜欢制造麻烦,她希望通过对 xx 和 yy 的恰当选择,使得“最小所需交换次数”这一数值尽可能大。她想知道:在所有可能的 (x,y)(x, y) 对中,哪一对能使所需的最小交换次数达到最大值?

由于 Icy 不擅长数学,她希望你能帮她解决这个问题。

输入格式

The first line of the input contains a single integer nn (2≤n≤2⋅1052 \le n \le 2 \cdot 10^5) — the number of chocolates.

The second line of the input contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n (0≤ai≤1090 \le a_i \le 10^9).

It is guaranteed that all aia_i are distinct.

输入的第一行包含一个整数 nn(2≤n≤2⋅1052 \le n \le 2 \cdot 10^5)—— 巧克力的数量。

输入的第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \dots, a_n(0≤ai≤1090 \le a_i \le 10^9)。

保证所有 aia_i 互不相同。

输出格式

Output three integers xx, yy, and mm.

xx and yy are indices of the optimal chocolates to perform exchanges on. Your output must satisfy 1≤x,y≤n1 \le x, y \le n, x≠yx \ne y.

mm is the number of exchanges needed to obtain ax=aya_x = a_y. We can show that m≤109m \le 10^9 for any pair of chocolates.

If there are multiple solutions, output any.

输出三个整数 xx、yy 和 mm。

xx 和 yy 是执行交换操作的最优巧克力的下标。你的输出必须满足 1≤x,y≤n1 \le x, y \le n 且 x≠yx \ne y。

mm 是使 ax=aya_x = a_y 所需的交换次数。可以证明:对于任意一对巧克力,均有 m≤109m \le 10^9。

若存在多个解,输出任意一个即可。

输入输出样例

  • 输入#1

    5
    5 6 7 8 9

    输出#1

    2 5 5
  • 输入#2

    2
    4 8

    输出#2

    1 2 2

说明/提示

In the first test case, the minimum number of exchanges needed to exchange a chocolate of type 66 to a chocolate of type 99 is 55. The sequence of exchanges is as follows: 6→2→0→1→7→96 \rightarrow 2 \rightarrow 0 \rightarrow 1 \rightarrow 7 \rightarrow 9.

In the second test case, the minimum number of exchanges needed to exchange a chocolate of type 44 to a chocolate of type 88 is 22. The sequence of exchanges is as follows: 4→0→84 \rightarrow 0 \rightarrow 8.

在第一个测试用例中,将类型为 66 的巧克力交换为类型为 99 的巧克力所需的最少交换次数为 55。交换序列为:6→2→0→1→7→96 \rightarrow 2 \rightarrow 0 \rightarrow 1 \rightarrow 7 \rightarrow 9。

在第二个测试用例中,将类型为 44 的巧克力交换为类型为 88 的巧克力所需的最少交换次数为 22。交换序列为:4→0→84 \rightarrow 0 \rightarrow 8。

输入解题思路,AI测评打分。不知道怎么写?

首页