luogu#P5522. [yLOI2019] 棠梨煎雪

    ID: 4226 远端评测题 1500ms 512MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>数学2019线段树树状数组O2优化位运算状压 DP

[yLOI2019] 棠梨煎雪

Background

Year after year, under the eaves with flower patterns, we boil snow with tangli,
From childhood to some day when you and I drift to the ends of the sky.
The sky is pale, the sky is blue; the night rain wets my clothes,
Once a year, the letters arrive, yet there are only a few words.

— Yinlin, “Tangli Jianxue”.

Problem Description

While Fusu was listening to “Tangli Jianxue”,

https://www.luogu.org/space/show?uid=61795
uoj.ac/problem/425): “I’ve solved this CTT problem, you trash Fusu, come and do it.” Fusu took a closer look—wasn’t this an s* problem? He coded and submitted it, only to find he had misread the statement. But the finished code could not be wasted, so this problem was created.

The protagonist in the lyrics and her friend write letters to each other once a year, for a total of mm years. To simplify the problem, we assume that the content of each letter is a binary code, and all binary codes have length nn. That is, each letter is a string of length nn containing only characters 0 or 1.

One day she took out all the letters her friend wrote to her. The letter written in year ii is numbered ii. Because the letters have been kept for too long, some characters have become blurred. We mark such positions as ?. A ? character can be interpreted as 0 or 1. Since her friend is also a human and thus follows human nature, the content written during a continuous period of time may be the same. Now she wants to ask you: for all letters in a continuous year interval [l,r][l,r], assuming her friend showed “human nature” in this period and wrote the same sentence, how many possible sentences can that sentence be? In other words, how many strings SS are there such that every letter in this interval could have content SS?

A string AA of length nn containing only 0,1,? could be a string BB if and only if BB satisfies:

  • The length of BB is also nn.
  • BB contains only characters 0,1.
  • Every position that is 0 in AA is also 0 in BB.
  • Every position that is 1 in AA is also 1 in BB.
  • Every position that is ? in AA can be 0 or 1 in BB.

She may also suddenly realize that she misread the content of some year’s letter, so she may modify the content of a certain year’s letter into another length-nn string containing only 0,1,?.

Input Format

Each input file contains exactly one test case.

The first line contains three integers separated by spaces, representing the string length nn, the number of strings mm, and the number of operations qq.

The next mm lines each contain a string of length nn. The string sis_i on line (i+1)(i + 1) represents the content of the letter in year ii.

The next qq lines describe operations. The first number of each line is the operation code optopt.

  • If opt=0opt=0, it is followed by two integers [l, r][l,~r], representing a query operation.
  • If opt=1opt=1, it is followed by an integer pospos, then after a space a string tt of length nn, representing modifying the pospos-th string to the new string tt.

Output Format

To avoid an excessively large output, output one line with one number: the XOR of the answers of all queries, and then XOR it with 00.

3 3 5
010
0?0
1?0
0 1 2
0 2 3
1 3 0??
0 2 3
0 1 3
2

Hint

Sample 1 Explanation

  • For the first query, only the string 010 satisfies the requirement.
  • For the second query, since the first bit of the second string is 0 and the first bit of the third string is 1, no string satisfies the requirement.
  • After the modification, the third string becomes 0??.
  • For the fourth query, there are two valid strings: 000 and 010.
  • For the fifth query, only 010 is valid.

Therefore the answers are 1,0,2,11,0,2,1. Their XOR, and then XOR with 00, equals 22.


Constraints

This problem uses bundled subtasks, with a total of 7 subtasks.

Subtask ID m=m = q=q = n=n = Subtask Score
11 00 11 55
22 102102 1010 1010
33 10031003 1515
44 10041004 1000410004 3030
55 100005100005 500005500005 11
66 100006100006 5000650006 3030 1010
77 100007100007 10000071000007 3030

For all testdata, it is guaranteed that:

  • 1m105+71 \leq m \leq 10^5 + 7, 0q106+70 \leq q \leq 10^6 + 7, 1n301 \leq n \leq 30.
  • 0opt10 \leq opt \leq 1, 1posm1 \leq pos \leq m, 1lrm1 \leq l \leq r \leq m.
  • The lengths of sis_i and tt are both nn, and they contain only 0,1,?.
  • The total length of input strings does not exceed 5×1065 \times 10^6. The data is generated under Linux, so line breaks do not include \r.

Hint

  • Please pay attention to the impact of constant factors on program efficiency.
  • Please pay attention to the impact of input reading on program efficiency.
  • Please note that the question mark in the input is the English question mark, whose ASCII value is 6363.

Note: To reduce the acceptance rate of incorrect solutions, the time limit was changed from 2000 ms to 1500 ms in July 2020.

Translated by ChatGPT 5