A14361 | Love-Hate
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
William is hosting a party for $n$ 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 $i$ it is known whether he likes currency $j$ . There are $m$ currencies in total. It is also known that a trader may not like more than $p$ 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 $\lceil \frac{n}{2} \rceil$ friends (rounded up) who like each currency in this subset.
For each William's friend $i$ it is known whether he likes currency $j$ . There are $m$ currencies in total. It is also known that a trader may not like more than $p$ 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 $\lceil \frac{n}{2} \rceil$ friends (rounded up) who like each currency in this subset.
输入格式
The first line contains three integers $n, m$ and $p$ $(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 $n$ lines contain $m$ characters. The $j$ -th character of $i$ -th line is $1$ if friend $i$ likes the currency $j$ and $0$ otherwise. It is guaranteed that the number of ones in each line does not exceed $p$ .
Each of the next $n$ lines contain $m$ characters. The $j$ -th character of $i$ -th line is $1$ if friend $i$ likes the currency $j$ and $0$ otherwise. It is guaranteed that the number of ones in each line does not exceed $p$ .
输出格式
Print a string of length $m$ , 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 $1$ .
If there are multiple answers, print any.
If there are multiple answers, print any.
输入输出样例
输入 #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 $\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 $2$ currencies and will be liked by friends $1$ , $2$ , and $5$ . 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.
In the second sample test case the answer includes $2$ currencies and will be liked by friends $1$ , $2$ , and $5$ . 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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted