#P4366. [Code+#4] 最短路

[Code+#4] 最短路

Description

There are NN cities in the Penguin Kingdom, numbered from 11 to NN.

For any two cities ii and jj, penguins can spend (i xor j)×C(i~\mathrm{xor}~j) \times C time to travel from city ii to city jj, where CC is a given constant.

In addition, there are MM one-way express channels. The ii-th express channel goes from city FiF_i to city TiT_i, and taking this channel costs ViV_i time.

Now a penguin named Doudou from Penguin Kingdom University is considering the minimum time needed to travel from city AA to city BB.

Input Format

Read from standard input.

The first line of input contains three integers N,M,CN,M,C (1C100)(1 \leq C \leq 100), representing the number of cities, the number of express channels, and the given constant CC mentioned in the statement.

The next MM lines each contain three positive integers Fi,Ti,ViF_i,T_i,V_i (1FiN1 \leq F_i \leq N, 1TiN,1Vi1001 \leq T_i \leq N, 1 \leq V_i \leq 100), representing the start city, the end city, and the time cost of taking this channel, respectively.

The last line contains two positive integers A,BA,B, representing the start city and the end city chosen by Doudou.

Output Format

Output to standard output.

Output one line with a single integer, the minimum time required to travel from city AA to city BB.

4 2 1
1 3 1
2 4 4
1 4
5
7 2 10
1 3 1
2 4 4
3 6
34

Hint

Sample 1 explanation.

It is optimal to go directly from 11 to 44.

Sample 2 explanation.

First go from 33 to 22, then take the channel from 22 to 44, and finally go from 44 to 66.

0

The lively and lovely problem setter left everyone the picture below.

1

Credit: https://www.luogu.org/discuss/show/38908

Translated by ChatGPT 5