QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 256 MB 總分: 100 可 Hack ✓

#7236. 集合交集

统计

给定 $(n + 1)$ 个集合。集合中的元素均为 $1$ 到 $2n$ 之间的整数。所有集合的大小均为 $n$。已知 $n$ 是偶数。

命题:总存在两个集合,它们的交集至少包含 $\frac{n}{2}$ 个元素。

任务:找出这样两个集合。

输入格式

第一行包含一个整数 $n$ ($1 \le n \le 6000$,$n$ 为偶数)。接下来的 $(n + 1)$ 行,每行包含 $\lceil \frac{2n}{6} \rceil$ 个字符。每行包含一个 $2n$ 位零一序列的编码。如果第 $i$ 个集合包含元素 $j$,则第 $i$ 个序列的第 $j$ 位为 $1$,否则为 $0$。因此,每个序列中恰好有 $n$ 个 $1$。

编码过程描述如下:考虑一个由 $0$ 和 $1$ 组成的序列 $a_0, a_1, a_2, \dots, a_{2n-1}$。在序列末尾补若干个 $0$ 使其长度能被 $6$ 整除。然后创建一个新序列:$b_0 = \sum_{j=0}^{5} a_j \cdot 2^j$,$b_1 = \sum_{j=0}^{5} a_{j+6} \cdot 2^j$,$b_2 = \sum_{j=0}^{5} a_{j+12} \cdot 2^j$,以此类推。

编码序列由 ASCII 码为 $33 + b_0, 33 + b_1, 33 + b_2, \dots$ 的字符组成。

输出格式

集合按输入顺序从 $1$ 到 $(n + 1)$ 编号。输出两个不同的整数:交集至少包含 $\frac{n}{2}$ 个元素的两个集合的编号。如果存在多个可能的答案,输出其中任意一个即可。

样例

输入 1

4
7"
*$
D#
M"
;"

输出 1

2 3

说明

解码后的序列:

  1. 01101010
  2. 10010011
  3. 11000101
  4. 00110110
  5. 01011010

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#147EditorialOpen题解jiangly2026-02-25 08:44:30View

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.