CF1004F.Sonya and Bitwise OR

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Sonya has an array a1,a2,,ana_1, a_2, \ldots, a_n consisting of nn integers and also one non-negative integer xx . She has to perform mm queries of two types:

  • 11 ii yy : replace ii -th element by value yy , i.e. to perform an operation aia_{i} := yy ;
  • 22 ll rr : find the number of pairs ( LL , RR ) that lLRrl\leq L\leq R\leq r and bitwise OR of all integers in the range [L,R][L, R] is at least xx (note that xx is a constant for all queries).

Can you help Sonya perform all her queries?

Bitwise OR is a binary operation on a pair of non-negative integers. To calculate the bitwise OR of two numbers, you need to write both numbers in binary notation. The result is a number, in binary, which contains a one in each digit if there is a one in the binary notation of at least one of the two numbers. For example, 1010 OR 1919 = 101021010_2 OR 10011210011_2 = 11011211011_2 = 2727 .

输入格式

The first line contains three integers nn , mm , and xx ( 1n,m1051\leq n, m\leq 10^5 , 0x<2200\leq x<2^{20} ) — the number of numbers, the number of queries, and the constant for all queries.

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n ( 0ai<2200\leq a_i<2^{20} ) — numbers of the array.

The following mm lines each describe an query. A line has one of the following formats:

  • 11 ii yy ( 1in1\leq i\leq n , 0y<2200\leq y<2^{20} ), meaning that you have to replace aia_{i} by yy ;
  • 22 ll rr ( 1lrn1\leq l\leq r\leq n ), meaning that you have to find the number of subarrays on the segment from ll to rr that the bitwise OR of all numbers there is at least xx .

输出格式

For each query of type 2, print the number of subarrays such that the bitwise OR of all the numbers in the range is at least xx .

输入输出样例

  • 输入#1

    4 8 7
    0 3 6 1
    2 1 4
    2 3 4
    1 1 7
    2 1 4
    2 1 3
    2 1 1
    1 3 0
    2 1 4
    

    输出#1

    5
    1
    7
    4
    1
    4
    
  • 输入#2

    5 5 7
    6 0 3 15 2
    2 1 5
    1 4 4
    2 1 5
    2 3 5
    2 1 4
    

    输出#2

    9
    7
    2
    4
    

说明/提示

In the first example, there are an array [ 00 , 33 , 66 , 11 ] and queries:

  1. on the segment [ 141\ldots4 ], you can choose pairs ( 11 , 33 ), ( 11 , 44 ), ( 22 , 33 ), ( 22 , 44 ), and ( 33 , 44 );
  2. on the segment [ 343\ldots4 ], you can choose pair ( 33 , 44 );
  3. the first number is being replacing by 77 , after this operation, the array will consist of [ 77 , 33 , 66 , 11 ];
  4. on the segment [ 141\ldots4 ], you can choose pairs ( 11 , 11 ), ( 11 , 22 ), ( 11 , 33 ), ( 11 , 44 ), ( 22 , 33 ), ( 22 , 44 ), and ( 33 , 44 );
  5. on the segment [ 131\ldots3 ], you can choose pairs ( 11 , 11 ), ( 11 , 22 ), ( 11 , 33 ), and ( 22 , 33 );
  6. on the segment [ 111\ldots1 ], you can choose pair ( 11 , 11 );
  7. the third number is being replacing by 00 , after this operation, the array will consist of [ 77 , 33 , 00 , 11 ];
  8. on the segment [ 141\ldots4 ], you can choose pairs ( 11 , 11 ), ( 11 , 22 ), ( 11 , 33 ), and ( 11 , 44 ).

In the second example, there are an array [ 66 , 00 , 33 , 1515 , 22 ] are queries:

  1. on the segment [ 151\ldots5 ], you can choose pairs ( 11 , 33 ), ( 11 , 44 ), ( 11 , 55 ), ( 22 , 44 ), ( 22 , 55 ), ( 33 , 44 ), ( 33 , 55 ), ( 44 , 44 ), and ( 44 , 55 );
  2. the fourth number is being replacing by 44 , after this operation, the array will consist of [ 66 , 00 , 33 , 44 , 22 ];
  3. on the segment [ 151\ldots5 ], you can choose pairs ( 11 , 33 ), ( 11 , 44 ), ( 11 , 55 ), ( 22 , 44 ), ( 22 , 55 ), ( 33 , 44 ), and ( 33 , 55 );
  4. on the segment [ 353\ldots5 ], you can choose pairs ( 33 , 44 ) and ( 33 , 55 );
  5. on the segment [ 141\ldots4 ], you can choose pairs ( 11 , 33 ), ( 11 , 44 ), ( 22 , 44 ), and ( 33 , 44 ).
首页