#P3733. [HAOI2017] 八纵八横

    ID: 1279 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2017河南线段树各省省选分治线性基

[HAOI2017] 八纵八横

Description

The country of Anihc has nn cities, numbered from 11 to nn, with city 11 being the capital. Initially, there are mm highways between cities. Each highway has a non-negative integer economic impact factor, and each highway connects two cities (the endpoints may be the same city). It is guaranteed that any two cities are mutually reachable via highways.

The country is planning the "Eight Verticals and Eight Horizontals" high-speed railway program, which will build some high-speed railways. Each railway also connects two cities (the endpoints may be the same city) and has a non-negative integer economic impact factor. After this program is completed, the country plans to extend the "Belt and Road" to "Belt and Road and Ring" by adding an "Inland Cities Economic Ring," i.e., choosing a path that starts from the capital and follows a sequence of railways and highways, where each railway or highway may be traversed multiple times, and each city may be visited multiple times, finally returning to the capital. Let the GDP of the "Inland Cities Economic Ring" be the XOR of the economic impact factors of the railways and highways traversed along this path in order (an edge traversed multiple times is counted multiple times).

Anihc is discussing the construction plan for "Eight Verticals and Eight Horizontals" and will keep modifying the plan. You are asked to report, in real time, the maximum possible GDP of the "Inland Cities Economic Ring" for the current plan.

Initially, the plan contains no railways. There are the following 33 types of operations:

Add x y z

Add a high-speed railway between cities xx and yy with economic impact factor zz. If this is the kk-th Add operation, then this railway is named railway kk.

Cancel k

Cancel railway kk from the plan. It is guaranteed that railway kk exists at this moment.

Change k z

Change the economic impact factor of railway kk to zz. It is guaranteed that railway kk exists at this moment.

Input Format

The first line contains 33 integers n,m,Qn, m, Q, denoting the number of cities, the number of highways, and the number of operations.

The next mm lines each contain 33 integers, describing a highway.

The next QQ lines each contain one operation, in one of the following forms: Add x y z, Cancel k, or Change k z.

Note: All economic impact factors in the input are given in binary, from the most significant bit to the least significant bit.

Output Format

Output one integer on the first line: the maximum possible GDP of the "Inland Cities Economic Ring" if no railway is built.

Then output QQ lines, each containing one integer, where the ii-th line is the maximum possible GDP of the "Inland Cities Economic Ring" after performing the ii-th operation with respect to the current plan.

Note: All answers must be output in binary, from the most significant bit to the least significant bit.

4 4 3
1 2 1110
1 3 10
2 4 1110
2 3 100
Add 3 4 11
Change 1 101
Cancel 1
1000
1001
1111
1000

Hint

Constraints and Notes.

Let lenlen be the maximum number of bits among the binary representations of all economic impact factors. The testdata satisfies the following table:

Data Point nn mm QQ lenlen Special Property
1 5\leq 5 8\leq 8 00 31\leq 31
2 100\leq 100 =n+1= n + 1 100\leq 100
3 100\leq 100
4 500\leq 500 1000\leq 1000
5 100\leq 100 200\leq 200 Only Add operations
6 500\leq 500 200\leq 200 1000\leq 1000
7 100\leq 100 1000\leq 1000 200\leq 200
8 500\leq 500 1000\leq 1000
9
10

For all testdata it is guaranteed that 1n,m5001 \leq n, m \leq 500, 0Q10000 \leq Q \leq 1000, 1len10001 \leq len \leq 1000, 1x,yn1 \leq x, y \leq n. Moreover, the number of Add operations does not exceed 550550. There may be multiple highways or railways between two cities, and an edge may have both endpoints at the same city (i.e., multiedges and self-loops).

Translated by ChatGPT 5