#P5651. 基础最短路练习题

基础最短路练习题

Description

Given a simple, undirected, connected graph GG with nn vertices and mm 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 GG whose edge-weight XOR sum is not 00.

There are QQ queries asking for the shortest simple path from xx to yy.

Input Format

The first line contains three positive integers n,m,Qn, m, Q.

The next mm lines each contain three non-negative integers x,y,vx, y, v (1x,yn1 \le x, y \le n), representing an undirected edge connecting xx and yy with weight vv. It is guaranteed that there are no multiple edges and no self-loops.

The next QQ lines each contain two positive integers x,yx, y (1x,yn1 \le x, y \le n), representing a query.

Output Format

Output QQ lines, each containing one integer as the answer.

3 2 1
1 2 2
2 3 3
1 3
1

Hint

Test Point ID n,Qn, Q \le Special Property
1,21,2 1010 None
3,43,4 2020
5,65,6 105{10}^5 m=n1m = n - 1
7,87,8 v1v \le 1
9,109,10 None

For 100%100\% of the testdata, 1n1051 \le n \le {10}^5, 1m2n1 \le m \le 2n, and 0v<2300 \le v < 2^{30}.

Translated by ChatGPT 5