Logo
(追記) (追記ここまで)

30300번 - AND MEX 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 1024 MB32812210640.152%

문제

We define the beauty of an array as the value of its minimum excluded value (MEX$^{\dagger}$). A larger MEX corresponds to a more beautiful array.

You are given an array $A$ of length $N$. You want to enhance it in terms of its beauty. To achieve this, you can choose a non-negative integer $x$ and replace each element $A_i$ with $A_i\wedge x$ where $\wedge$ denotes the bitwise AND operator.

Find the optimal value of $x$ that maximizes the beauty of the array.

입력

The first line contains a single integer $T$ --- the number of test cases.

The first line of each test case contains a single integer $N$.

The second line of each test case contains $N$ space-separated integers $A_1,\ldots ,A_N$.

출력

For each test case, print a single line containing a single integer $x$ that maximizes the MEX of the array formed by taking the bitwise AND of each element of $A$ with $x$. If there are multiple solutions, you may print any.

제한

  • 1ドル\le T\le 100,円 000$
  • 1ドル\le N\le 100,円 000$
  • 0ドル\le A_i<2^{30}\ (1\le i\le N)$
  • It is guaranteed that the sum of $N$ over all test cases does not exceed 100ドル,円 000$.
  • All values in the input are integers.
  • 0ドル\le x<2^{30}$
  • It can be shown that there always exists an optimal $x$ in the specified range.

예제 입력 1

1
6
13 11 40 10 33 19

예제 출력 1

23

노트

In the sample, we can choose $x=23,ドル so the new array will be \[[13\wedge 23,,円 11\wedge 23,,円 40\wedge 23,10\wedge 23,,円 33\wedge 23,,円 19\wedge 23] =[5,3,0,2,1,19]\] which has a MEX of 4ドル$. Another possible answer is $x=19$.

${}^{\dagger}$ The MEX of an array is the smallest non-negative integer that does not belong to the array. For instance, the MEX of $[2,2,1]$ is 0ドル,ドル the MEX of $[3,1,0,1]$ is 2ドル,ドル and the MEX of $[0,3,1,2]$ is 4ドル$.

출처

University > KAIST > KAIST ICPC Mock Competition > 2023 KAIST 13th ICPC Mock Competition I번

Camp > Petrozavodsk Programming Camp > Summer 2024 > Day 2: K-ontest I번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /