AT_arc227_d.Median of Binary Strings
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given length-M strings S1,S2,…,SN consisting of 0 and 1.
Initially, S1,S2,…,SN 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,C. Newly write on the blackboard a string D of length M satisfying the following condition:
- For each i=1,2,…,M, letting Ai,Bi,Ci,Di denote the i-th characters of A,B,C,D, respectively, Di is equal to at least two of Ai,Bi,Ci.
You are given Q strings T1,T2,…,TQ. For each i=1,2,…,Q, determine whether it is possible to make Ti be written on the blackboard by performing operations starting from the initial state.
给你 N 个长度为 M 的字符串 S1,S2,…,SN,每个字符串仅由字符 0 和 1 构成。
初始时,黑板上写有字符串 S1,S2,…,SN。
你可以执行以下操作零次或多次:
- 从黑板上已有的字符串中任选三个(允许重复选取同一字符串),记为 A,B,C;然后在黑板上新写出一个长度为 M 的字符串 D,满足如下条件:
- 对每个 i=1,2,…,M,设 Ai,Bi,Ci,Di 分别为 A,B,C,D 的第 i 个字符,则 Di 等于 Ai,Bi,Ci 中至少两个的值。
再给你 Q 个字符串 T1,T2,…,TQ。对每个 i=1,2,…,Q,判断是否能从初始状态出发、通过若干次上述操作,使得 Ti 出现在黑板上。
输入格式
The input is given from Standard Input in the following format:
N M Q
S1
S2
⋮
SN
T1
T2
⋮
TQ
输入从标准输入中按以下格式给出:
N M Q
S1
S2
⋮
SN
T1
T2
⋮
TQ
输出格式
Output Q lines. The i-th line should contain Yes if Ti can be made to be written on the blackboard, and No otherwise.
输出 Q 行。第 i 行应包含 Yes(如果 Ti 可以被写在黑板上),否则为 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:
T1 is written on the blackboard from the beginning.
T2 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≤500
- 1≤M≤500
- 1≤Q≤500
- Si is a string of length M consisting of
0and1. (1≤i≤N) - Ti is a string of length M consisting of
0and1. (1≤i≤Q) - All input values are integers.
样例 1 解释:
T1 从一开始就被写在黑板上。
T2 是 001。若我们选择字符串 000、011、101 执行该操作,则可在黑板上新写出 001。
样例 2 解释:
黑板上初始写出的两个字符串均为 0,且通过该操作新写出的字符串也必为 0。因此,不可能使 1 出现在黑板上。
约束条件
- 1≤N≤500
- 1≤M≤500
- 1≤Q≤500
- Si 是一个长度为 M、仅由字符
0和1组成的字符串。(1≤i≤N) - Ti 是一个长度为 M、仅由字符
0和1组成的字符串。(1≤i≤Q) - 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?