QOJ.ac

QOJ

Süre Sınırı: 2 s Bellek Sınırı: 1024 MB Toplam puan: 100

#1168. 求互斥或

İstatistikler

有一個連通圖 $G$,由 $N$ 個頂點同 $M$ 條有權無向邊組成。喺 $G$ 入面,一條路徑嘅權重係將路徑上全部邊嘅權重逐一做 XOR(互斥或)而得到。留意,同一條邊可以行多次,咁樣佢嘅權重亦會做相同次數嘅 XOR。

對頂點 $u$ 同 $v$,設 $d(u,v)$ 係由 $u$ 到 $v$ 嘅路徑權重最大值。

你需要回答 $Q$ 個以下形式嘅查詢:

畀定 $l$ 同 $r$,對所有滿足 $l\le i<j\le r$ 嘅 $i,j$,求所有 $d(i,j)$ 值嘅 XOR。

輸入

第一行包含三個整數 $N,M,Q$($1\le N,M,Q\le10^5$)。

接落嚟 $M$ 行,每行包含三個整數 $u,v,w$,描述一條連接頂點 $u$ 同 $v$、權重為 $w$ 嘅邊($1\le u,v\le N$,$0\le w<2^{30}$)。留意,呢題允許重邊同自環。

接落嚟 $Q$ 行,每行描述一個查詢,包含兩個整數 $l$ 同 $r$($1\le l<r\le N$)。

輸出

對每個查詢,獨立一行輸出答案。

樣例

輸入 1

8 10 7
1 2 662784558
3 2 195868257
3 4 294212653
4 5 299265014
6 5 72652580
6 7 29303370
7 8 183954825
2 1 752722885
5 3 197591314
8 4 877461873
4 8
5 7
6 7
2 3
7 8
3 4
2 7

輸出 1

0
713437792
738051848
716356296
736682272
1003204975
987493236

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.