AtCoder Regular Contest 227
D
二进制字符串的中位数
Median of Binary Strings
AtCoder
⌀ 2277
原题
← CE →

二进制字符串的中位数AI (CI翻译)

Problem Statement

题目描述

AI (CI翻译)

You are given length-$M$ strings $S_1,S_2,\ldots,S_N$ consisting of 0 and 1.

给定 $N$ 个长度为 $M$、由 0 和 1 组成的字符串 $S_1,S_2,\ldots,S_N$。AI (CI翻译)

Initially, $S_1,S_2,\ldots,S_N$ are written on the blackboard.

初始时,黑板上写有 $S_1,S_2,\ldots,S_N$。AI (CI翻译)

You can perform the following operation zero or more times.

你可以进行零次或多次如下操作。AI (CI翻译)

  • Choose three strings from those written on the blackboard, allowing the same string to be chosen multiple times, and call them $A,B,C$. Newly write on the blackboard a string $D$ of length $M$ satisfying the following condition:
  • For each $i=1,2,\ldots,M$, letting $A_i,B_i,C_i,D_i$ denote the $i$-th characters of $A,B,C,D$, respectively, $D_i$ is equal to at least two of $A_i,B_i,C_i$.
  • 从黑板上写有的字符串中选择三个字符串,允许多次选择同一个字符串,并将它们记为 $A,B,C$。然后在黑板上新写下一个长度为 $M$ 的字符串 $D$,使其满足以下条件:
  • 对于每个 $i=1,2,\ldots,M$,设 $A_i,B_i,C_i,D_i$ 分别表示 $A,B,C,D$ 的第 $i$ 个字符,则 $D_i$ 至少与 $A_i,B_i,C_i$ 中的两个相等。
AI (CI翻译)

You are given $Q$ strings $T_1,T_2,\ldots,T_Q$. For each $i=1,2,\ldots,Q$, determine whether it is possible to make $T_i$ be written on the blackboard by performing operations starting from the initial state.

给定 $Q$ 个字符串 $T_1,T_2,\ldots,T_Q$。对于每个 $i=1,2,\ldots,Q$,判断是否可以从初始状态开始进行若干次操作,使得 $T_i$ 被写在黑板上。AI (CI翻译)

Constraints

约束条件

AI (CI翻译)
  • $1 \leq N \leq 500$
  • $1 \leq M \leq 500$
  • $1 \leq Q \leq 500$
  • $S_i$ is a string of length $M$ consisting of 0 and 1. $(1 \leq i \leq N)$
  • $T_i$ is a string of length $M$ consisting of 0 and 1. $(1 \leq i \leq Q)$
  • All input values are integers.
  • $1 \leq N \leq 500$
  • $1 \leq M \leq 500$
  • $1 \leq Q \leq 500$
  • $S_i$ 是一个长度为 $M$、由 0 和 1 组成的字符串。$(1 \leq i \leq N)$
  • $T_i$ 是一个长度为 $M$、由 0 和 1 组成的字符串。$(1 \leq i \leq Q)$
  • 所有输入值均为整数。
AI (CI翻译)

Input

输入格式

AI (CI翻译)

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

输入从标准输入读入,格式如下:AI (CI翻译)

N M Q
S_1
S_2
\vdots
S_N
T_1
T_2
\vdots
T_Q

N M Q
S_1
\vdots
S_N
T_1
\vdots
T_Q
AI (CI翻译)

Output

输出格式

AI (CI翻译)

Output $Q$ lines. The $i$-th line should contain Yes if $T_i$ can be made to be written on the blackboard, and No otherwise.

输出 $Q$ 行。第 $i$ 行应包含 Yes,如果可以使 $T_i$ 被写在黑板上;否则输出 No。AI (CI翻译)

样例

Input #1
3 3 2
000
011
101
000
001
Output #1
Yes
Yes
$T_1$ is written on the blackboard from the beginning. $T_2$ is `001`. If we perform the operation choosing the three strings `000`, `011`, `101`, we can newly write `001` on the blackboard.
Input #2
2 1 2
0
0
0
1
Output #2
Yes
No
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.
题目信息
题号
arc227_d
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。