این مسابقه به صورت حضوری در تاریخ ۱۴ آذر ۱۴۰۳ در سایت دانشکده برق و کامپیوتر دانشگاه تهران برگزار می‌شود. علاقه‌مندان می‌توانند به صورت همزمان در مسابقه آنلاین که شامل همان سوالات می‌باشد شرکت کنند.

Rook attack


  • محدودیت زمان: ۲ ثانیه
  • محدودیت حافظه: ۶۴ مگابایت

Zeinab is a huge fan of chess and programming, but typical chess soon became boring for her, so she started having fun with rook pieces.

She found a chessboard with NN rows and NN columns and placed KK rooks on it. Zeinab’s game is made of the following rules:

  • Each rook’s power is determined by an integer.
  • A rook sees all the fields that are in his row or column except its own field.
  • We say that a field is attacked if the binary XOR of all the powers of the rooks that see the field is greater than 0.

Notice that the field a rook is at can be attacked or not. Initially, Zeinab placed the rooks in a certain layout on the board and will make P moves. After each move, determine how many fields are attacked. Every rook can be moved to any free field on the whole board (not only across column and row).

Input🔗

The first line of input contains integers N, K and P.

Each of the following K lines contains three integers R, C, X. which denote that initially there is a rook of power X on the field (R, C).

Each of the following P lines contains four integers r1r_1, c1c_1, r2r_2, c2c_2 which denote that the rook has moved from field (r1,c1)(r_1, c_1) to field (r2,c2)(r_2, c_2).

Output🔗

The output must consist of P lines, the kthk^{th} line containing the total number of attacked fields after kk moves.

Constraints🔗

  • 1N1091 \leq N \leq 10^9
  • 1P,K1051 \leq P,K \leq 10^5
  • 1R,CN1 \leq R,C \leq N
  • 0X1090 \leq X \leq 10^9
  • 0r1,c1,r2,c2N0 \leq r_1,c_1,r_2,c_2 \leq N

Sample Test Data🔗

input 1🔗

2 2 2
1 1 1
2 2 2
2 2 2 1
1 1 1 2
Plain text

output 1🔗

4
2
Plain text
ارسال پاسخ برای این سؤال
در حال حاضر شما دسترسی ندارید.