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 NN participants, numbered 11 to NN, and at most MM of them can pass the preliminary round.

The preliminary round consists of KK two-choice quiz questions, and the answer to each question is o or x.
Participant ii's answer to the jj-th question is given as the jj-th character of the string SiS_i.
The correct answer to the jj-th question is given as the jj-th character of the string TT.

The qualifiers are determined by the following procedure.

  • Initially, the numbers of qualifiers and non-qualifiers are both 00; all NN participants are undetermined.
  • For k=1,2,…,Kk=1,2,\dots,K in this order, perform the following process.
    • If the number of qualifiers plus the number of undetermined participants who answered the kk-th question correctly is at most MM, then all undetermined participants who answered the kk-th question correctly become qualifiers.
    • Otherwise, all undetermined participants who answered the kk-th question incorrectly become non-qualifiers.
  • All remaining undetermined participants become non-qualifiers.

You are given QQ queries in the following format. Process them in order.

  • Integers ii and jj are given. Change participant ii's answer to the jj-th question from o to x, or from x to o. Then, determine whether participant ii passes the preliminary round.

The change of the answer in each query remains in effect when processing subsequent queries as well.

一场知识竞赛的预赛已经举行。共有 NN 名参赛者,编号为 11 至 NN,其中至多 MM 人能够通过预赛。

预赛包含 KK 道判断题,每道题的答案为 o 或 x。
第 ii 名参赛者对第 jj 道题的回答由字符串 SiS_i 的第 jj 个字符给出。
第 jj 道题的正确答案由字符串 TT 的第 jj 个字符给出。

晋级者的确定过程如下:

  • 初始时,晋级者人数与未晋级者人数均为 00;全部 NN 名参赛者状态均未确定。
  • 按照 k=1,2,…,Kk = 1, 2, \dots, K 的顺序,依次执行以下步骤:
    • 若“当前晋级者人数”加上“所有状态未确定且第 kk 道题回答正确的参赛者人数”不超过 MM,则所有状态未确定且第 kk 道题回答正确的参赛者均成为晋级者;
    • 否则,所有状态未确定且第 kk 道题回答错误的参赛者均成为未晋级者。
  • 所有剩余状态未确定的参赛者均成为未晋级者。

现给出 QQ 个查询,格式如下。请按顺序处理每个查询:

  • 给定整数 ii 和 jj。将第 ii 名参赛者对第 jj 道题的回答翻转(即 o 变为 x,或 x 变为 o)。随后,判断第 ii 名参赛者是否通过预赛。

每次查询中对答案的修改在后续查询中持续有效。

输入格式

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

NN MM KK
TT
S1S_1
⋮\vdots
SNS_N
QQ
query1\mathrm{query}_1
⋮\vdots
queryQ\mathrm{query}_Q

Here, queryq\mathrm{query}_q represents the qq-th query, and is given in the following format:

ii jj

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

NN MM KK
TT
S1S_1
⋮\vdots
SNS_N
QQ
query1\mathrm{query}_1
⋮\vdots
queryQ\mathrm{query}_Q

其中,queryq\mathrm{query}_q 表示第 qq 个查询,其格式如下:

ii jj

输出格式

Output QQ lines.
The qq-th line should contain Yes if the participant specified in the qq-th query passes the preliminary round, and No otherwise.

输出 QQ 行。
第 qq 行应包含 Yes(如果第 qq 个查询中指定的参赛者通过预赛),否则包含 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,21,2 pass on the first question and participant 33 passes on the second question, so the qualifiers are the three participants 1,2,31,2,3.
  • After the first query, participants 1,2,51,2,5 pass on the first question, so the qualifiers are the three participants 1,2,51,2,5. Since participant 55 passes the preliminary round, output Yes.
  • After the second query, participants 1,2,51,2,5 still pass on the first question, so the qualifiers are the three participants 1,2,51,2,5. Since participant 11 passes the preliminary round, output Yes.
  • After the third query, participant 33 is eliminated on the first question, participants 1,21,2 pass on the second question, and participant 55 passes on the third question, so the qualifiers remain the three participants 1,2,51,2,5. Since participant 44 does not pass the preliminary round, output No.

Constraints

  • 1≤M≤N≤3×1041 \leq M \leq N \leq 3\times 10^4
  • 1≤K≤2001 \leq K \leq 200
  • SiS_i and TT are strings of length KK consisting of o and x.
  • 1≤Q≤5×1041 \leq Q \leq 5\times 10^4
  • For each query, 1≤i≤N1\leq i \leq N and 1≤j≤K1 \leq j \leq K.

样例 1 解释:

  • 第一次查询前,参与者 1,21,2 通过了第一题,参与者 33 通过了第二题,因此晋级者为参与者 1,2,31,2,3。
  • 第一次查询后,参与者 1,2,51,2,5 通过了第一题,因此晋级者为参与者 1,2,51,2,5。由于参与者 55 通过了预选轮,输出 Yes。
  • 第二次查询后,参与者 1,2,51,2,5 仍通过了第一题,因此晋级者仍为参与者 1,2,51,2,5。由于参与者 11 通过了预选轮,输出 Yes。
  • 第三次查询后,参与者 33 在第一题被淘汰,参与者 1,21,2 通过了第二题,参与者 55 通过了第三题,因此晋级者仍为参与者 1,2,51,2,5。由于参与者 44 未通过预选轮,输出 No。

限制条件

  • 1≤M≤N≤3×1041 \leq M \leq N \leq 3\times 10^4
  • 1≤K≤2001 \leq K \leq 200
  • SiS_i 和 TT 均为长度为 KK 的字符串,仅由字符 o 和 x 组成。
  • 1≤Q≤5×1041 \leq Q \leq 5\times 10^4
  • 对于每次查询,满足 1≤i≤N1\leq i \leq N 且 1≤j≤K1 \leq j \leq K。

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

首页