Time Limit: 2 sec / Memory Limit: 256 MB
配点 : 800 点
問題文
N 匹のうさぎがいます。 うさぎ達は 1 から N まで番号が振られています。 最初、うさぎ i は数直線上の座標 x_i にいます。
うさぎ達は体操をすることにしました。 1 セット分の体操は、次のような合計 M 回のジャンプからなります。 j 回目のジャンプでは、うさぎ a_j (2≤a_j≤N-1) がジャンプします。 このとき、うさぎ a_j-1 かうさぎ a_j+1 のどちらかが等確率で選ばれ(これをうさぎ x とします)、うさぎ a_j はうさぎ x に関して対称な座標へジャンプします。
以上の合計 M 回のジャンプを 1 セット分の体操として、うさぎ達は K セット分の体操を続けて繰り返します。 各うさぎについて、最終的な座標の期待値を求めてください。
制約
- 3≤N≤10^5
- x_i は整数である。
- |x_i|≤10^9
- 1≤M≤10^5
- 2≤a_j≤N-1
- 1≤K≤10^{18}
入力
入力は以下の形式で標準入力から与えられる。
N x_1 x_2 ... x_N M K a_1 a_2 ... a_M
出力
N 行出力せよ。 i 行目には、うさぎ i の最終的な座標の期待値を出力せよ。 絶対誤差または相対誤差が 10^{-9} 以下ならば正解となる。
入力例 1
3 -1 0 2 1 1 2
出力例 1
-1.0 1.0 2.0
うさぎ 2 がジャンプします。 うさぎ 1 に関して対称な座標へジャンプすると、座標 -2 へ移動します。 うさぎ 3 に関して対称な座標へジャンプすると、座標 4 へ移動します。 よって、うさぎ 2 の最終的な座標の期待値は 0.5×(-2)+0.5×4=1.0 です。
入力例 2
3 1 -1 1 2 2 2 2
出力例 2
1.0 -1.0 1.0
x_i は相異なるとは限りません。
入力例 3
5 0 1 3 6 10 3 10 2 3 4
出力例 3
0.0 3.0 7.0 8.0 10.0
Score : 800 points
Problem Statement
There are N rabbits on a number line. The rabbits are conveniently numbered 1 through N. The coordinate of the initial position of rabbit i is x_i.
The rabbits will now take exercise on the number line, by performing sets described below. A set consists of M jumps. The j-th jump of a set is performed by rabbit a_j (2≤a_j≤N-1). For this jump, either rabbit a_j-1 or rabbit a_j+1 is chosen with equal probability (let the chosen rabbit be rabbit x), then rabbit a_j will jump to the symmetric point of its current position with respect to rabbit x.
The rabbits will perform K sets in succession. For each rabbit, find the expected value of the coordinate of its eventual position after K sets are performed.
Constraints
- 3≤N≤10^5
- x_i is an integer.
- |x_i|≤10^9
- 1≤M≤10^5
- 2≤a_j≤N-1
- 1≤K≤10^{18}
Input
The input is given from Standard Input in the following format:
N x_1 x_2 ... x_N M K a_1 a_2 ... a_M
Output
Print N lines. The i-th line should contain the expected value of the coordinate of the eventual position of rabbit i after K sets are performed. The output is considered correct if the absolute or relative error is at most 10^{-9}.
Sample Input 1
3 -1 0 2 1 1 2
Sample Output 1
-1.0 1.0 2.0
Rabbit 2 will perform the jump. If rabbit 1 is chosen, the coordinate of the destination will be -2. If rabbit 3 is chosen, the coordinate of the destination will be 4. Thus, the expected value of the coordinate of the eventual position of rabbit 2 is 0.5×(-2)+0.5×4=1.0.
Sample Input 2
3 1 -1 1 2 2 2 2
Sample Output 2
1.0 -1.0 1.0
x_i may not be distinct.
Sample Input 3
5 0 1 3 6 10 3 10 2 3 4
Sample Output 3
0.0 3.0 7.0 8.0 10.0