#P10963. [2015杭电多校]In Touch
[2015杭电多校]In Touch
In Touch
Problem Description
There are n soda living in a straight line. soda are numbered by from left to right. The distance between two adjacent soda is 1 meter. Every soda has a teleporter. The teleporter of -th soda can teleport to the soda whose distance between -th soda is no less than and no larger than . The cost to use -th soda's teleporter is . The -st soda is their leader and he wants to know the minimum cost needed to reach -th soda .
Input
There are multiple test cases. The first line of input contains an integer , indicating the number of test cases. For each test case: The first line contains an integer , the number of soda. The second line contains integers . The third line contains integers . The fourth line contains integers .
Output
For each case, output integers where -th integer denotes the minimum cost needed to reach -th soda. If -st soda cannot reach -the soda, you should just output -1.
Sample Input
1
5
2 0 0 0 1
3 1 1 0 5
1 1 1 1 1
Sample Output
0 2 1 1 -1
Hint
If you need a larger stack size, please use #pragma comment(linker, "/STACK:102400000,102400000") and submit your solution using C++.
Author
zimpha@zju
Source
2015 Multi-University Training Contest 6