#P6532. [COCI 2015/2016 #1] TOPOVI

[COCI 2015/2016 #1] TOPOVI

Description

There is an n×nn \times n chessboard with kk pieces on it. Each piece has a power value wiw_i.

We define the following rules:

  • The attack range of a piece is the row and the column it is in, excluding its own cell.
  • A cell on the board is considered attacked if and only if the XOR sum of the power values of all pieces that can attack it is greater than 00.

Now we will perform pp operations. After each operation, output the total number of cells that are attacked.

Input Format

The first line contains three integers n,k,pn,k,p.

The next kk lines each contain three integers xi,yi,wix_i,y_i,w_i. The ii-th line means there is a piece at position (xi,yi)(x_i,y_i) with power value wiw_i.

The next pp lines each contain four integers r1,c1,r2,c2r_1,c_1,r_2,c_2, meaning the piece at (r1,c1)(r_1,c_1) is moved to (r2,c2)(r_2,c_2).

Output Format

Output pp lines. Each line contains one integer. The ii-th line is the total number of cells that are attacked after the ii-th operation.

2 2 2
1 1 1
2 2 1
2 2 2 1
1 1 1 2 

4
0 
2 2 2
1 1 1
2 2 2
2 2 2 1
1 1 1 2 

4
2
3 3 4
1 1 1
2 2 2
2 3 3
2 3 3 3
3 3 3 1
1 1 1 2
3 1 3 2 

6
7
7
9

Hint

Constraints

  • For 25%25\% of the testdata, n,k100n,k \le 100.
  • For 100%100\% of the testdata, 1n1091 \le n \le 10^9, 1k1051 \le k \le 10^5, 1p1051 \le p \le 10^5, 1xi,yi,r1,c1,r2,c2n1 \le x_i,y_i,r_1,c_1,r_2,c_2 \le n, 1wi1091 \le w_i \le 10^9. During movements, pieces will not overlap.

Notes

This problem is worth 120 points.

This problem is translated from T4 TOPOVI, Croatian Open Competition in Informatics 2015/2016 Contest #1.

Translated by ChatGPT 5