#P8826. [传智杯 #3 初赛] 游戏(征集数据)

[传智杯 #3 初赛] 游戏(征集数据)

Description

Qingzhengyu is an unbeaten player in the game “Chilan Xianye”. One day, he encountered the following game:

You are given an array aa of length nn. Also define count(x)count(x) as the number of 11 bits in the binary representation of xx.

Each time, Qingzhengyu can perform one of the following two operations:

  • Choose two numbers ai,aja_i, a_j, and it must satisfy count(aixoraj)=1count(a_i \operatorname{xor} a_j)=1. Delete either one of them from the array, with cost C1C_1.

  • Choose two numbers ai,aja_i, a_j, and it must satisfy count(aixoraj)>1count(a_i \operatorname{xor} a_j) > 1. Delete either one of them from the array, with cost C2C_2.

You want to know the minimum total cost to delete numbers until only one number remains in the array.

Input Format

The first line contains an integer nn, which is the size of the array.
The second line contains two integers C1,C2C_1, C_2, with meanings as described above.
The third line contains nn integers, describing the array aa.

Output Format

Output one integer in one line, representing the minimum cost.

4
5 10
1 2 3 4
20

Hint

For 20%20\% of the testdata, n=10n = 10.
For another 20%20\% of the testdata, the elements in aa form a permutation of [1,n][1, n].
For 100%100\% of the testdata, 1n1041 \leq n \leq {10}^4, 1C1,C2,a1091 \le C_1, C_2, a \le {10}^9, and all elements in aa are distinct.

Translated by ChatGPT 5