#P16596. 【四川省集】仙人掌最小值查询
【四川省集】仙人掌最小值查询
Problem Description
Given a connected undirected edge cactus graph with edge weights, answer multiple queries. For each query, find the minimum possible XOR sum of edge weights along a vertex-simple (no repeated vertices) path between two given nodes.
Note: The original graph may contain multiple edges and self-loops. A cycle formed by a pair of parallel edges is also considered a cycle. Self-loops clearly do not affect this problem.
Input Format
The first line contains three integers , where is the number of vertices, is the number of edges, and is the number of queries.
The next lines each contain three integers , meaning there is an edge between and with weight .
The next lines each contain two integers , meaning: query the minimum XOR value of edge weights over all vertex-simple paths between and .
Output Format
Output lines. Each line contains one integer, the answer to the -th query in order.
4 4 3
1 2 1
2 3 2
3 4 3
4 2 4
1 4
1 3
2 4
0
3
1
Hint
Sample Explanation

The first query: .
The second query: .
The third query: .
Constraints
For all testdata, . The detailed constraints are as follows:
| Subtask | Score | |||
|---|---|---|---|---|
Special Notes
The testdata for this problem is not easy to create, and there are many wrong solutions or solutions with too high time complexity, so it may be quite strict on constant factors. You are welcome to submit hack testdata.
Currently, common wrong solutions that are not guaranteed to be hacked include:
- Let me see whether can pass.
- I think heavy-light decomposition with can pass.
- I guess long-chain decomposition / binary lifting linear basis with can pass.
- I think tree blocking + linear basis can pass.
- Various boundary issues, and so on.
Translated by ChatGPT 5