AT_arc227_d.Median of Binary Strings

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

You are given length-MM strings S1,S2,…,SNS_1,S_2,\ldots,S_N consisting of 0 and 1.

Initially, S1,S2,…,SNS_1,S_2,\ldots,S_N are written on the blackboard.

You can perform the following operation zero or more times.

  • Choose three strings from those written on the blackboard, allowing the same string to be chosen multiple times, and call them A,B,CA,B,C. Newly write on the blackboard a string DD of length MM satisfying the following condition:
    • For each i=1,2,…,Mi=1,2,\ldots,M, letting Ai,Bi,Ci,DiA_i,B_i,C_i,D_i denote the ii-th characters of A,B,C,DA,B,C,D, respectively, DiD_i is equal to at least two of Ai,Bi,CiA_i,B_i,C_i.

You are given QQ strings T1,T2,…,TQT_1,T_2,\ldots,T_Q. For each i=1,2,…,Qi=1,2,\ldots,Q, determine whether it is possible to make TiT_i be written on the blackboard by performing operations starting from the initial state.

给你 NN 个长度为 MM 的字符串 S1,S2,…,SNS_1, S_2, \ldots, S_N,每个字符串仅由字符 0 和 1 构成。

初始时,黑板上写有字符串 S1,S2,…,SNS_1, S_2, \ldots, S_N。

你可以执行以下操作零次或多次:

  • 从黑板上已有的字符串中任选三个(允许重复选取同一字符串),记为 A,B,CA, B, C;然后在黑板上新写出一个长度为 MM 的字符串 DD,满足如下条件:
    • 对每个 i=1,2,…,Mi = 1, 2, \ldots, M,设 Ai,Bi,Ci,DiA_i, B_i, C_i, D_i 分别为 A,B,C,DA, B, C, D 的第 ii 个字符,则 DiD_i 等于 Ai,Bi,CiA_i, B_i, C_i 中至少两个的值。

再给你 QQ 个字符串 T1,T2,…,TQT_1, T_2, \ldots, T_Q。对每个 i=1,2,…,Qi = 1, 2, \ldots, Q,判断是否能从初始状态出发、通过若干次上述操作,使得 TiT_i 出现在黑板上。

输入格式

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

NN MM QQ
S1S_1
S2S_2
⋮\vdots
SNS_N
T1T_1
T2T_2
⋮\vdots
TQT_Q

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

NN MM QQ
S1S_1
S2S_2
⋮\vdots
SNS_N
T1T_1
T2T_2
⋮\vdots
TQT_Q

输出格式

Output QQ lines. The ii-th line should contain Yes if TiT_i can be made to be written on the blackboard, and No otherwise.

输出 QQ 行。第 ii 行应包含 Yes(如果 TiT_i 可以被写在黑板上),否则为 No。

输入输出样例

  • 输入#1

    3 3 2
    000
    011
    101
    000
    001

    输出#1

    Yes
    Yes
  • 输入#2

    2 1 2
    0
    0
    0
    1

    输出#2

    Yes
    No

说明/提示

Sample 1 Explanation:
T1T_1 is written on the blackboard from the beginning.

T2T_2 is 001. If we perform the operation choosing the three strings 000, 011, 101, we can newly write 001 on the blackboard.

Sample 2 Explanation:
The strings initially written on the blackboard are both 0, and the string newly written by the operation is also 0. Therefore, it is impossible to make 1 be written on the blackboard.

Constraints

  • 1≤N≤5001 \leq N \leq 500
  • 1≤M≤5001 \leq M \leq 500
  • 1≤Q≤5001 \leq Q \leq 500
  • SiS_i is a string of length MM consisting of 0 and 1. (1≤i≤N)(1 \leq i \leq N)
  • TiT_i is a string of length MM consisting of 0 and 1. (1≤i≤Q)(1 \leq i \leq Q)
  • All input values are integers.

样例 1 解释:
T1T_1 从一开始就被写在黑板上。

T2T_2 是 001。若我们选择字符串 000、011、101 执行该操作,则可在黑板上新写出 001。

样例 2 解释:
黑板上初始写出的两个字符串均为 0,且通过该操作新写出的字符串也必为 0。因此,不可能使 1 出现在黑板上。

约束条件

  • 1≤N≤5001 \leq N \leq 500
  • 1≤M≤5001 \leq M \leq 500
  • 1≤Q≤5001 \leq Q \leq 500
  • SiS_i 是一个长度为 MM、仅由字符 0 和 1 组成的字符串。(1≤i≤N)(1 \leq i \leq N)
  • TiT_i 是一个长度为 MM、仅由字符 0 和 1 组成的字符串。(1≤i≤Q)(1 \leq i \leq Q)
  • 所有输入值均为整数。

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

首页