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

33053번 - All Pairs Similarity 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB48171337.143%

문제

Farmer John's $N$ (1ドル\le N\le 5\cdot 10^5$) cows are each assigned a bitstring of length $K$ that is not all zero (1ドル\le K\le 20$). Different cows may be assigned the same bitstring.

The Jaccard similarity of two bitstrings is defined as the number of set bits in their bitwise intersection divided by the number of set bits in their bitwise union. For example, the Jaccard similarity of the bitstrings 11001 and 11010 would be 2ドル/4$.

For each cow, output the sum of her bitstring's Jaccard similarity with each of the $N$ cows' bitstrings including her own, modulo 10ドル^9+7$. Specifically, if the sum is equal to a rational number $a/b$ where $a$ and $b$ are integers sharing no common factors, output the unique integer $x$ in the range $[0,10^9+7)$ such that $bx-a$ is divisible by 10ドル^9+7$.

입력

The first line contains $N$ and $K$.

The next $N$ lines each contain an integer $i\in (0,2^K),ドル representing a cow associated with the length-$K$ binary representation of $i$.

출력

Output the sum modulo 10ドル^9+7$ for each cow on a separate line.

제한

예제 입력 1

4 2
1
1
2
3

예제 출력 1

500000006
500000006
500000005
500000006

힌트

The cows are associated with the following bitstrings: $[$01, 01, 10, 11$]$.

For the first cow, the sum is $\text{sim}(1,1)+\text{sim}(1,1)+\text{sim}(1,2)+\text{sim}(1,3)=1+1+0+1/2\equiv 500000006\pmod{10^9+7}$.

The second cow's bitstring is the same as the first cow's, so her sum is the same as above.

For the third cow, the sum is

$\text{sim}(2,1)+\text{sim}(2,1)+\text{sim}(2,2)+\text{sim}(2,3)=0+0+1+1/2\equiv 500000005\pmod{10^9+7}$.

출처

Olympiad > USA Computing Olympiad > 2024-2025 Season > USACO 2024 December Contest > Platinum 1번

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

출처

대학교 대회

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

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