RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0636

All Pairs Similarity

Diamond III 다이아몬드 III
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

*Note: The memory limit for this problem is 512MB, twice the default.*

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 \(\texttt{11001}\) and
\(\texttt{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\).

Problem credits: Benjamin Qi

제약

SCORING

  • Inputs 2-15: There will be two test cases for each of \(K\in \{10,15,16,17,18,19,20\}\).

Problem credits: Benjamin Qi

입력 형식

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\).

출력 형식
예제 1
입력
4 2
1
1
2
3
출력
500000006
500000006
500000005
500000006
설명

The cows are associated with the following bitstrings:
\([\texttt{01}, \texttt{01}, \texttt{10}, \texttt{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}\).

문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2024-2025 > December > Platinum

태그

평가 및 의견

All Pairs Similarity

개요
출제자 난이도 Diamond III 다이아몬드 III 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

All Pairs Similarity

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8