#P4366. Penguin Kingdom Travel Time
Penguin Kingdom Travel Time
Penguin Kingdom Travel Time
In Penguin Kingdom, there are cities, numbered from to . For any two distinct cities and , a penguin can travel from to in ( (i \oplus j) \times C ) time (where ( \oplus ) denotes the bitwise XOR operation and is a given constant). Additionally, there are one-way shortcut channels. The -th shortcut channel runs from city to city and takes time. Given two cities and , determine the minimum time required to travel from city to city .
inputFormat
The first line contains five integers: , , , , and . Each of the following lines contains three integers , , and , describing a shortcut channel from city to with time cost .
outputFormat
Output a single integer representing the minimum time required to travel from city to city .
sample
4 1 1 1 4
2 3 1
5
</p>