CF1523D.Love-Hate

提高+/省选-

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

William is hosting a party for nn of his trader friends. They started a discussion on various currencies they trade, but there's an issue: not all of his trader friends like every currency. They like some currencies, but not others.

For each William's friend ii it is known whether he likes currency jj. There are mm currencies in total. It is also known that a trader may not like more than pp currencies.

Because friends need to have some common topic for discussions they need to find the largest by cardinality (possibly empty) subset of currencies, such that there are at least ⌈n2⌉\lceil \frac{n}{2} \rceil friends (rounded up) who like each currency in this subset.

威廉正在为他的 nn 位交易员朋友举办一场聚会。朋友们开始讨论他们所交易的各种货币,但存在一个问题:并非所有朋友都喜欢每一种货币。他们只喜欢其中一部分货币,而对另一些则不感兴趣。

对于威廉的每位朋友 ii,已知他是否喜欢货币 jj。总共有 mm 种货币。此外还已知:每位交易员最多只喜欢 pp 种货币。

由于朋友们需要一个共同话题来展开讨论,因此他们需要找出一个基数最大(允许为空集)的货币子集,使得该子集中每一种货币都至少被 ⌈n2⌉\lceil \frac{n}{2} \rceil 位朋友(向上取整)所喜欢。

输入格式

The first line contains three integers n,mn, m and pp (1≤n≤2⋅105,1≤p≤m≤60,1≤p≤15)(1 \le n \le 2 \cdot 10^5, 1 \le p \le m \le 60, 1 \le p \le 15), which is the number of trader friends, the number of currencies, the maximum number of currencies each friend can like.

Each of the next nn lines contain mm characters. The jj-th character of ii-th line is 11 if friend ii likes the currency jj and 00 otherwise. It is guaranteed that the number of ones in each line does not exceed pp.

第一行包含三个整数 n,mn, m 和 pp (1≤n≤2⋅105,1≤p≤m≤60,1≤p≤15)(1 \le n \le 2 \cdot 10^5, 1 \le p \le m \le 60, 1 \le p \le 15),分别表示交易员朋友的数量、货币种类数以及每位朋友最多喜欢的货币种类数。

接下来的 nn 行,每行包含 mm 个字符。第 ii 行的第 jj 个字符为 11 表示第 ii 位朋友喜欢第 jj 种货币,为 00 则表示不喜欢。保证每行中字符 11 的个数不超过 pp。

输出格式

Print a string of length mm, which defines the subset of currencies of the maximum size, which are liked by at least half of all friends. Currencies belonging to this subset must be signified by the character 11.

If there are multiple answers, print any.

输出一个长度为 mm 的字符串,该字符串表示一个最大规模的货币子集,该子集中的每种货币至少被一半的朋友喜欢。属于该子集的货币需用字符 11 表示。

若存在多个答案,输出任意一个即可。

输入输出样例

  • 输入#1

    3 4 3
    1000
    0110
    1001

    输出#1

    1000
  • 输入#2

    5 5 4
    11001
    10101
    10010
    01110
    11011

    输出#2

    10001

说明/提示

In the first sample test case only the first currency is liked by at least ⌈32⌉=2\lceil \frac{3}{2} \rceil = 2 friends, therefore it's easy to demonstrate that a better answer cannot be found.

In the second sample test case the answer includes 22 currencies and will be liked by friends 11, 22, and 55. For this test case there are other currencies that are liked by at least half of the friends, but using them we cannot achieve a larger subset size.

在第一个样例测试用例中,只有第一种货币被至少 ⌈32⌉=2\lceil \frac{3}{2} \rceil = 2 位朋友喜欢,因此容易证明无法找到更优的答案。

在第二个样例测试用例中,答案包含 22 种货币,且将被朋友 11、22 和 55 喜欢。对于该测试用例,存在其他被至少一半朋友喜欢的货币,但使用它们无法获得更大的子集规模。

输入解题思路,AI测评打分。不知道怎么写?

首页