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

33128번 - Xorderable Array 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB56222142.000%

문제

You are given an array $A$ of $N$ integers: $[A_1, A_2, \dots , A_N ]$.

The array $A$ is $(p, q)$-xorderable if it is possible to rearrange $A$ such that for each pair $(i, j)$ that satisfies 1ドル ≤ i < j ≤ N,ドル the following conditions must be satisfied after the rearrangement: $A_i \oplus p ≤ A_j \oplus q$ and $A_i \oplus q ≤ A_j \oplus p$. The operator $\oplus$ represents the bitwise xor.

You are given another array $X$ of length $M$: $[X_1, X_2, \dots , X_M]$. Calculate the number of pairs $(u, v)$ where array $A$ is $(X_u, X_v)$-xorderable for 1ドル ≤ u < v ≤ M$.

입력

The first line consists of two integers $N$ $M$ (2ドル ≤ N, M ≤ 200,円 000$).

The second line consists of $N$ integers $A_i$ (0ドル ≤ A_i < 2^{30}$).

The third line consists of $M$ integers $X_u$ (0ドル ≤ X_u < 2^{30}$).

출력

Output a single integer representing the number of pairs $(u, v)$ where array $A$ is $(X_u, X_v)$-xorderable for 1ドル ≤ u < v ≤ M$.

제한

예제 입력 1

3 4
0 3 0
1 2 1 1

예제 출력 1

3

The array $A$ is $(1, 1)$-xorderable by rearranging the array $A$ to $[0, 0, 3]$.

예제 입력 2

5 2
0 7 13 22 24
12 10

예제 출력 2

1

The array $A$ is $(12, 10)$-xorderable by rearranging the array $A$ to $[13, 0, 7, 24, 22]$.

예제 입력 3

3 3
0 0 0
1 2 3

예제 출력 3

0

힌트

출처

ICPC > Regionals > Asia Pacific > Indonesia > Jakarta > The 2024 ICPC Asia Jakarta Regional Contest J번

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

출처

대학교 대회

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

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