AT_arc219_a.Similarity

普及-

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

You are given NN distinct strings S1,…,SNS_1, \dots, S_N. Each of these strings is a string of length MM consisting of 0 and 1.

Determine whether there exists a string TT of length MM consisting of 0 and 1 satisfying the following condition, and if so, construct one example.

  • Every string SiS_i matches TT in at least one position.
    • More formally, for every integer ii (1≤i≤N1 \le i \le N), there exists an integer xix_i (1≤xi≤M1 \le x_i \le M) such that the xix_i-th character of SiS_i and the xix_i-th character of TT are the same.

给你 NN 个互不相同的字符串 S1,…,SNS_1, \dots, S_N。每个字符串长度均为 MM,且仅由字符 0 和 1 组成。

判断是否存在一个长度为 MM、仅由 0 和 1 组成的字符串 TT,满足以下条件;若存在,请构造出一个例子。

  • 每个字符串 SiS_i 至少在一个位置上与 TT 匹配。
    • 更准确地说,对每个整数 ii(1≤i≤N1 \le i \le N),均存在一个整数 xix_i(1≤xi≤M1 \le x_i \le M),使得 SiS_i 的第 xix_i 个字符与 TT 的第 xix_i 个字符相同。

输入格式

The input is given from Standard Input in the following format:

NN MM
S1S_1
⋮\vdots
SNS_N

输入从标准输入中按以下格式给出:

NN MM
S1S_1
⋮\vdots
SNS_N

输出格式

If no TT satisfying the condition in the problem statement exists, output No.

If a TT satisfying the condition in the problem statement exists, output in the following format:

Yes
TT

If multiple TT satisfying the condition exist, any of them will be accepted.

如果不存在满足题目条件的 TT,则输出 No。

如果存在满足题目条件的 TT,则按以下格式输出:

Yes
TT

若存在多个满足条件的 TT,输出其中任意一个即可。

输入输出样例

  • 输入#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 TT to 101, the following holds:

  • The 22nd character of S1S_1 and the 22nd character of TT are the same.
  • The 11st character of S2S_2 and the 11st character of TT are the same.
  • The 11st character of S3S_3 and the 11st character of TT are the same.
  • The 22nd character of S4S_4 and the 22nd character of TT are the same.
  • The 33rd character of S5S_5 and the 33rd character of TT are the same.

Sample 2 Explanation:
No TT satisfies the condition.

Constraints

  • NN and MM are integers.
  • 1≤N≤2×1041 \leq N \leq 2 \times 10^4
  • 1≤M≤1001 \leq M \leq 100
  • SiS_i is a string of length MM consisting of 0 and 1.
  • S1,…,SNS_1, \dots, S_N are distinct.

样例 1 解释:
若我们令 TT 为 101,则以下条件成立:

  • S1S_1 的第 22 个字符与 TT 的第 22 个字符相同。
  • S2S_2 的第 11 个字符与 TT 的第 11 个字符相同。
  • S3S_3 的第 11 个字符与 TT 的第 11 个字符相同。
  • S4S_4 的第 22 个字符与 TT 的第 22 个字符相同。
  • S5S_5 的第 33 个字符与 TT 的第 33 个字符相同。

样例 2 解释:
不存在满足条件的 TT。

限制条件

  • NN 和 MM 是整数。
  • 1≤N≤2×1041 \leq N \leq 2 \times 10^4
  • 1≤M≤1001 \leq M \leq 100
  • SiS_i 是一个长度为 MM 的字符串,仅由字符 0 和 1 组成。
  • S1,…,SNS_1, \dots, S_N 互不相同。

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

首页