AT_arc219_a.Similarity
普及-
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given N distinct strings S1,…,SN. Each of these strings is a string of length M consisting of 0 and 1.
Determine whether there exists a string T of length M consisting of 0 and 1 satisfying the following condition, and if so, construct one example.
- Every string Si matches T in at least one position.
- More formally, for every integer i (1≤i≤N), there exists an integer xi (1≤xi≤M) such that the xi-th character of Si and the xi-th character of T are the same.
给你 N 个互不相同的字符串 S1,…,SN。每个字符串长度均为 M,且仅由字符 0 和 1 组成。
判断是否存在一个长度为 M、仅由 0 和 1 组成的字符串 T,满足以下条件;若存在,请构造出一个例子。
- 每个字符串 Si 至少在一个位置上与 T 匹配。
- 更准确地说,对每个整数 i(1≤i≤N),均存在一个整数 xi(1≤xi≤M),使得 Si 的第 xi 个字符与 T 的第 xi 个字符相同。
输入格式
The input is given from Standard Input in the following format:
N M
S1
⋮
SN
输入从标准输入中按以下格式给出:
N M
S1
⋮
SN
输出格式
If no T satisfying the condition in the problem statement exists, output No.
If a T satisfying the condition in the problem statement exists, output in the following format:
Yes
T
If multiple T satisfying the condition exist, any of them will be accepted.
如果不存在满足题目条件的 T,则输出 No。
如果存在满足题目条件的 T,则按以下格式输出:
Yes
T
若存在多个满足条件的 T,输出其中任意一个即可。
输入输出样例
输入#1
5 3 000 111 110 100 011
输出#1
Yes 101
输入#2
4 2 00 01 10 11
输出#2
No
输入#3
9 50 00001000011111100011111000011111000001000001111100 00010100010000010100000100100000100011000010000010 00100010010000010100000000000000100101000010000010 01000001011111100100000000011111000001000001111110 01111111010001000100000000100000000001000000000010 01000001010000100100000100100000000001000010000010 01000001010000010011111000111111100111110001111100 00000000000000000000000000000000000000000000000000 11111111111111111111111111111111111111111111111111
输出#3
Yes 10101010101010101010101011010101011010101101010101
说明/提示
Sample 1 Explanation:
If we set T to 101, the following holds:
- The 2nd character of S1 and the 2nd character of T are the same.
- The 1st character of S2 and the 1st character of T are the same.
- The 1st character of S3 and the 1st character of T are the same.
- The 2nd character of S4 and the 2nd character of T are the same.
- The 3rd character of S5 and the 3rd character of T are the same.
Sample 2 Explanation:
No T satisfies the condition.
Constraints
- N and M are integers.
- 1≤N≤2×104
- 1≤M≤100
- Si is a string of length M consisting of
0and1. - S1,…,SN are distinct.
样例 1 解释:
若我们令 T 为 101,则以下条件成立:
- S1 的第 2 个字符与 T 的第 2 个字符相同。
- S2 的第 1 个字符与 T 的第 1 个字符相同。
- S3 的第 1 个字符与 T 的第 1 个字符相同。
- S4 的第 2 个字符与 T 的第 2 个字符相同。
- S5 的第 3 个字符与 T 的第 3 个字符相同。
样例 2 解释:
不存在满足条件的 T。
限制条件
- N 和 M 是整数。
- 1≤N≤2×104
- 1≤M≤100
- Si 是一个长度为 M 的字符串,仅由字符
0和1组成。 - S1,…,SN 互不相同。
输入解题思路,AI测评打分。不知道怎么写?