#P4308. [CTSC2011] 幸福路径

    ID: 3243 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2011倍增WC/CTSC/集训队枚举,暴力

[CTSC2011] 幸福路径

Description

There is a directed graph GG with nn vertices 1,2,,n1, 2, \cdots, n, and the weight of vertex ii is w(i)w(i).

An ant starts from a given starting vertex v0v_0 and crawls along the edges of GG. Initially, its stamina is 11. Each time it traverses an edge, its stamina is multiplied by ρ\rho, where ρ\rho is a given positive constant less than 11. When the ant reaches a vertex, its happiness is the product of its current stamina and the weight of that vertex.

We denote the total happiness along the crawling path by HH. Clearly, for different crawling paths, the value of HH may differ. Xiao Z is interested in the maximum possible value of HH. Can you help compute it? Note that the length of the ant’s path may be infinite.

Input Format

Numbers on each line are separated by a single space.

The first line contains two positive integers n,mn, m, the number of vertices and edges in GG.

The second line contains nn non-negative real numbers, representing the vertex weights w(1),w(2),,w(n)w(1), w(2), \cdots, w(n).

The third line contains a positive integer v0v_0, the given starting vertex.

The fourth line contains a real number ρ\rho, the given positive constant less than 11.

Each of the next mm lines contains two positive integers x,yx, y, indicating that (x,y)(x, y) is a directed edge of GG. Self-loops may exist, but there are no multiple edges.

Output Format

Output a single real number: the maximum possible value of HH, rounded to one decimal place.

5 5 
10.0 8.0 8.0 8.0 15.0 
1 
0.5 
1 2 
2 3 
3 4 
4 2 
4 5
18.0

Hint

For 100%100\% of the testdata, 1n1001 \leq n \le 100, 1m10001 \leq m \le 1000, 0<ρ11060 < \rho \le 1 - 10^{-6}, 0w(i)1000 \leq w(i) \leq 100.

Translated by ChatGPT 5