#P5651. 基础最短路练习题
基础最短路练习题
Description
Given a simple, undirected, connected graph with vertices and edges. Each edge has a weight. It is guaranteed that there are no multiple edges and no self-loops.
Define the weight of a simple path as the XOR sum of the weights of all edges on the path.
It is guaranteed that there is no simple cycle in whose edge-weight XOR sum is not .
There are queries asking for the shortest simple path from to .
Input Format
The first line contains three positive integers .
The next lines each contain three non-negative integers (), representing an undirected edge connecting and with weight . It is guaranteed that there are no multiple edges and no self-loops.
The next lines each contain two positive integers (), representing a query.
Output Format
Output lines, each containing one integer as the answer.
3 2 1
1 2 2
2 3 3
1 3
1
Hint
| Test Point ID | Special Property | |
|---|---|---|
| None | ||
| None |
For of the testdata, , , and .
Translated by ChatGPT 5
京公网安备 11011102002149号