CF1847D.Professor Higashikata

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Josuke is tired of his peaceful life in Morioh. Following in his nephew Jotaro's footsteps, he decides to study hard and become a professor of computer science. While looking up competitive programming problems online, he comes across the following one:

Let ss be a binary string of length nn . An operation on ss is defined as choosing two distinct integers ii and jj ( 1i<jn1 \leq i < j \leq n ), and swapping the characters si,sjs_i, s_j .

Consider the mm strings t1,t2,,tmt_1, t_2, \ldots, t_m , where tit_i is the substring ^\dagger of ss from lil_i to rir_i . Define t(s)=t1+t2++tmt(s) = t_1+t_2+\ldots+t_m as the concatenation of the strings tit_i in that order.

There are qq updates to the string. In the ii -th update sxis_{x_i} gets flipped. That is if sxi=1s_{x_i}=1 , then sxis_{x_i} becomes 00 and vice versa. After each update, find the minimum number of operations one must perform on ss to make t(s)t(s) lexicographically as large ^\ddagger as possible.

Note that no operation is actually performed. We are only interested in the number of operations.

Help Josuke in his dream by solving the problem for him.

—————————————————————— \dagger A string aa is a substring of a string bb if aa can be obtained from bb by the deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.

\ddagger A string aa is lexicographically larger than a string bb of the same length if and only if the following holds:

  • in the first position where aa and bb differ, the string aa has a 11 , and the string bb has a 00 .

输入格式

The first line contains three integers nn , mm , qq ( 1n,m,q21051 \leq n,m,q \leq 2 \cdot 10^5 ).

The next line contains a binary string ss of length nn , consisting only of digits 00 and 11 .

The ii -th line of the next mm lines contains two integers lil_i and rir_i ( 1lirin1 \leq l_i \leq r_i \leq n ).

The ii -th line of the next qq lines contains a single integer xix_i ( 1xin1 \leq x_i \leq n ).

输出格式

Print qq integers. The ii -th integer is the minimum number of operations that need to be performed on ss to get the lexicographically largest possible string t(s)t(s) in the ii -th round.

输入输出样例

  • 输入#1

    2 2 4
    01
    1 2
    1 2
    1
    1
    2
    2

    输出#1

    0
    1
    0
    1
  • 输入#2

    8 6 10
    10011010
    5 6
    2 3
    6 8
    5 7
    5 8
    6 8
    3
    5
    6
    2
    5
    2
    5
    8
    4
    1

    输出#2

    2
    3
    2
    2
    1
    2
    2
    2
    2
    2

说明/提示

In the first test case,

Originally, t(s)=s(1,2)+s(1,2)=0101t(s) = s(1,2) + s(1,2) = 0101 .

After the 11 -st query, ss becomes 1111 and consequently tt becomes 11111111 . You don't need to perform any operation as t(s)t(s) is already the lexicographically largest string possible.

After the 22 -nd query, ss becomes 0101 and consequently tt becomes 01010101 . You need to perform 11 operation by swapping s1s_1 and s2s_2 . Consequently, t(s)t(s) becomes 10101010 which is the lexicographically largest string you can achieve.

首页