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

Cowmistry

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

의견: 0

설명

Bessie has been procrastinating on her cow-mistry homework and now needs your
help! She needs to create a mixture of three different cow-michals. As all good
cows know though, some cow-michals cannot be mixed with each other or else they
will cause an explosion. In particular, two cow-michals with labels \(a\) and \(b\)
can only be present in the same mixture if \(a \oplus b \le K\)
(\(1 \le K \le 10^9\)).

NOTE: Here, \(a\oplus b\) denotes the "bitwise exclusive or'' of non-negative
integers \(a\) and \(b\). This operation is equivalent to adding each corresponding
pair of bits in base 2 and discarding the carry. For example,
$$ 0\oplus 0=1\oplus 1=0, $$
$$ 1\oplus 0=0\oplus 1=1, $$
$$ 5\oplus 7=101_2\oplus 111_2=010_2=2. $$

Bessie has \(N\) (\(1\le N\le 2\cdot 10^4\)) boxes of cow-michals and the \(i\)-th box contains cow-michals
labeled \(l_i\) through \(r_i\) inclusive \((0\le l_i \le r_i \le 10^9)\). No two
boxes have any cow-michals in common. She wants to know how many unique mixtures
of three different cow-michals she can create. Two mixtures are considered
different if there is at least one cow-michal present in one but not the other.
Since the answer may be very large, report it modulo \(10^9 + 7\).

Problem credits: Benjamin Qi

제약

SCORING

  • Test cases 3-4 satisfy \(\max(K,r_N)\le 10^4\).
  • Test cases 5-6 satisfy \(K=2^k-1\) for some integer \(k\ge 1\).
  • Test cases 7-11 satisfy \(\max(K,r_N)\le 10^6\).
  • Test cases 12-16 satisfy \(N\le 20\).
  • Test cases 17-21 satisfy no additional constraints.

Problem credits: Benjamin Qi

입력 형식

The first line contains two integers \(N\) and \(K\).

Each of the next \(N\) lines contains two space-separated integers \(l_i\) and
\(r_i\). It is guaranteed that the boxes of cow-michals are provided in increasing
order of their contents; namely, \(r_i for each \(1\le i.

출력 형식

The number of mixtures of three different cow-michals Bessie can create, modulo
\(10^9 + 7\).

예제 1
입력
1 13
0 199
출력
4280
설명

We can split the chemicals into 13 groups that cannot cross-mix: \((0\ldots 15)\),
\((16\ldots 31)\), \(\ldots\) \((192\ldots 199)\). Each of the first twelve groups
contributes \(352\) unique mixtures and the last contributes \(56\) (since all
\(\binom{8}{3}\) combinations of three different cow-michals from
\((192\ldots 199)\) are okay), for a total of
\(352\cdot 12+56=4280\).

예제 2
입력
6 147
1 35
48 103
125 127
154 190
195 235
240 250
출력
267188
문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2020-2021 > December > Platinum

태그

평가 및 의견

Cowmistry

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

Log in to rate problems.

개별 의견

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

풀이 제출

Cowmistry

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