CF1617E.Christmas Chocolates

普及/提高-

通过率:0%

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 ( 1x,yn1 \le x, y \le n , xyx \ne y ).

In a chocolate exchange, Icy's grandparents choose a non-negative integer kk , such that 2kax2^k \ge a_x , and change the type of the chocolate xx from axa_x to 2kax2^k - a_x (that is, perform ax:=2kaxa_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.

输入格式

The first line of the input contains a single integer nn ( 2n21052 \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 ( 0ai1090 \le a_i \le 10^9 ).

It is guaranteed that all aia_i are distinct.

输出格式

Output three integers xx , yy , and mm .

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

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

If there are multiple solutions, output any.

输入输出样例

  • 输入#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: 6201796 \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: 4084 \rightarrow 0 \rightarrow 8 .

首页