AT_abc475_e.Quiz Competition: Qualifiers
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A preliminary round of a quiz competition was held. There are N participants, numbered 1 to N, and at most M of them can pass the preliminary round.
The preliminary round consists of K two-choice quiz questions, and the answer to each question is o or x.
Participant i's answer to the j-th question is given as the j-th character of the string Si.
The correct answer to the j-th question is given as the j-th character of the string T.
The qualifiers are determined by the following procedure.
- Initially, the numbers of qualifiers and non-qualifiers are both 0; all N participants are undetermined.
- For k=1,2,…,K in this order, perform the following process.
- If the number of qualifiers plus the number of undetermined participants who answered the k-th question correctly is at most M, then all undetermined participants who answered the k-th question correctly become qualifiers.
- Otherwise, all undetermined participants who answered the k-th question incorrectly become non-qualifiers.
- All remaining undetermined participants become non-qualifiers.
You are given Q queries in the following format. Process them in order.
- Integers i and j are given. Change participant i's answer to the j-th question from
otox, or fromxtoo. Then, determine whether participant i passes the preliminary round.
The change of the answer in each query remains in effect when processing subsequent queries as well.
一场知识竞赛的预赛已经举行。共有 N 名参赛者,编号为 1 至 N,其中至多 M 人能够通过预赛。
预赛包含 K 道判断题,每道题的答案为 o 或 x。
第 i 名参赛者对第 j 道题的回答由字符串 Si 的第 j 个字符给出。
第 j 道题的正确答案由字符串 T 的第 j 个字符给出。
晋级者的确定过程如下:
- 初始时,晋级者人数与未晋级者人数均为 0;全部 N 名参赛者状态均未确定。
- 按照 k=1,2,…,K 的顺序,依次执行以下步骤:
- 若“当前晋级者人数”加上“所有状态未确定且第 k 道题回答正确的参赛者人数”不超过 M,则所有状态未确定且第 k 道题回答正确的参赛者均成为晋级者;
- 否则,所有状态未确定且第 k 道题回答错误的参赛者均成为未晋级者。
- 所有剩余状态未确定的参赛者均成为未晋级者。
现给出 Q 个查询,格式如下。请按顺序处理每个查询:
- 给定整数 i 和 j。将第 i 名参赛者对第 j 道题的回答翻转(即
o变为x,或x变为o)。随后,判断第 i 名参赛者是否通过预赛。
每次查询中对答案的修改在后续查询中持续有效。
输入格式
The input is given from Standard Input in the following format:
N M K
T
S1
⋮
SN
Q
query1
⋮
queryQ
Here, queryq represents the q-th query, and is given in the following format:
i j
输入从标准输入中按以下格式给出:
N M K
T
S1
⋮
SN
Q
query1
⋮
queryQ
其中,queryq 表示第 q 个查询,其格式如下:
i j
输出格式
Output Q lines.
The q-th line should contain Yes if the participant specified in the q-th query passes the preliminary round, and No otherwise.
输出 Q 行。
第 q 行应包含 Yes(如果第 q 个查询中指定的参赛者通过预赛),否则包含 No。
输入输出样例
输入#1
5 3 3 oxo oxo oxx xxo xox xoo 3 5 1 1 3 4 1
输出#1
Yes Yes No
输入#2
3 1 2 ox xo oo ox 4 3 1 1 1 2 2 1 2
输出#2
No No Yes No
输入#3
1 1 1 o o 2 1 1 1 1
输出#3
No Yes
说明/提示
Sample 1 Explanation:
- Before the first query, participants 1,2 pass on the first question and participant 3 passes on the second question, so the qualifiers are the three participants 1,2,3.
- After the first query, participants 1,2,5 pass on the first question, so the qualifiers are the three participants 1,2,5. Since participant 5 passes the preliminary round, output
Yes. - After the second query, participants 1,2,5 still pass on the first question, so the qualifiers are the three participants 1,2,5. Since participant 1 passes the preliminary round, output
Yes. - After the third query, participant 3 is eliminated on the first question, participants 1,2 pass on the second question, and participant 5 passes on the third question, so the qualifiers remain the three participants 1,2,5. Since participant 4 does not pass the preliminary round, output
No.
Constraints
- 1≤M≤N≤3×104
- 1≤K≤200
- Si and T are strings of length K consisting of
oandx. - 1≤Q≤5×104
- For each query, 1≤i≤N and 1≤j≤K.
样例 1 解释:
- 第一次查询前,参与者 1,2 通过了第一题,参与者 3 通过了第二题,因此晋级者为参与者 1,2,3。
- 第一次查询后,参与者 1,2,5 通过了第一题,因此晋级者为参与者 1,2,5。由于参与者 5 通过了预选轮,输出
Yes。 - 第二次查询后,参与者 1,2,5 仍通过了第一题,因此晋级者仍为参与者 1,2,5。由于参与者 1 通过了预选轮,输出
Yes。 - 第三次查询后,参与者 3 在第一题被淘汰,参与者 1,2 通过了第二题,参与者 5 通过了第三题,因此晋级者仍为参与者 1,2,5。由于参与者 4 未通过预选轮,输出
No。
限制条件
- 1≤M≤N≤3×104
- 1≤K≤200
- Si 和 T 均为长度为 K 的字符串,仅由字符
o和x组成。 - 1≤Q≤5×104
- 对于每次查询,满足 1≤i≤N 且 1≤j≤K。
输入解题思路,AI测评打分。不知道怎么写?