#P15078. [ICPC 2024 Chengdu R] Expanding Array

[ICPC 2024 Chengdu R] Expanding Array

题目描述

Given an integer array a1,a2,,ana_1, a_2, \ldots, a_n of length nn, you can perform any number of operations on this array. In each operation, you can choose two adjacent elements aia_i and ai+1a_{i+1} (1i<n1 \le i < n), and insert one of the following three values between them: ai and ai+1a_i \ \texttt{and}\ a_{i+1}, ai or ai+1a_i \ \texttt{or}\ a_{i+1}, or aiai+1a_i \oplus a_{i+1}. Your task is to determine the maximum number of distinct values that can exist in the array after performing any number of operations.

Note:\textbf{Note:} x and yx \ \texttt{and}\ y represents the bitwise AND of xx and yy. x or yx \ \texttt{or}\ y represents the bitwise OR of xx and yy. xyx \oplus y represents the bitwise XOR (exclusive OR) of xx and yy.

输入格式

The first line contains a single integer nn (2n1052 \le n \le 10^5), representing the length of the array.

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (0ai1090 \le a_i \le 10^9), representing the elements of the array.

输出格式

Output a single integer, representing the maximum number of distinct values that can be obtained in the array after performing any number of operations.

2
2 3
4
2
3 4
4