AtCoder Beginner Contest 252
Ex
K-th beautiful Necklace
AtCoder
⌀ 3015
原题
←G →
翻译中…

Problem Statement

翻译中…

We have $N$ gemstones. The color and beauty of the $i$-th gemstone are $D_i$ and $V_i$, respectively. Here, the color of each gemstone is one of $1, 2, \ldots, C$, and there is at least one gemstone of each color.

翻译中…

Out of the $N$ gemstones, we will choose $C$ with distinct colors and use them to make a necklace. (The order does not matter.) The beautifulness of the necklace will be the bitwise $\rm XOR$ of the chosen gemstones.

翻译中…

Among all possible ways to make a necklace, find the beautifulness of the necklace made in the way with the $K$-th greatest beautifulness. (If there are multiple ways with the same beautifulness, we count all of them.)

翻译中…

What is bitwise $\rm XOR$? The bitwise $\rm XOR$ of integers $A$ and $B$, $A \oplus B$, is defined as follows: When $A \oplus B$ is written in base two, the digit in the $2^k$'s place ($k \geq 0$) is $1$ if either $A$ or $B$, but not both, has $1$ in the $2^k$'s place, and $0$ otherwise. For example, $3 \oplus 5 = 6$. (In base two: $011 \oplus 101 = 110$.)

翻译中…

Constraints

翻译中…
  • $1 \leq C \leq N \leq 70$
  • $1 \leq D_i \leq C$
  • $0 \leq V_i < 2^{60}$
  • $1 \leq K \leq 10^{18}$
  • There are at least $K$ ways to make a necklace.
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N C K
D_1 V_1
\vdots
D_N V_N

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
4 2 3
2 4
2 6
1 2
1 3
Output #1
5
There are four ways to make a necklace, as follows. - Choose the $1$-st and $3$-rd gemstones to make a necklace with the beautifulness of $4\ {\rm XOR}\ 2 =6$. - Choose the $1$-st and $4$-th gemstones to make a necklace with the beautifulness of $4\ {\rm XOR}\ 3 =7$. - Choose the $2$-nd and $3$-rd gemstones to make a necklace with the beautifulness of $6\ {\rm XOR}\ 2 =4$. - Choose the $2$-nd and $4$-th gemstones to make a necklace with the beautifulness of $6\ {\rm XOR}\ 3 =5$. Thus, the necklace with the $3$-rd greatest beautifulness has the beautifulness of $5$.
Input #2
3 1 2
1 0
1 0
1 0
Output #2
0
There are three ways to make a necklace, all of which result in the beautifulness of $0$.
Input #3
10 3 11
1 414213562373095048
1 732050807568877293
2 236067977499789696
2 449489742783178098
2 645751311064590590
2 828427124746190097
3 162277660168379331
3 316624790355399849
3 464101615137754587
3 605551275463989293
Output #3
766842905529259824
题目信息
题号
abc252_h
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。