Codeforces Round 958 (Div. 2) |
---|
Finished |
For an array $$$[a_1,a_2,\ldots,a_n]$$$ of length $$$n$$$, define $$$f(a)$$$ as the sum of the minimum element over all subsegments. That is, $$$$$$f(a)=\sum_{l=1}^n\sum_{r=l}^n \min_{l\le i\le r}a_i.$$$$$$
A permutation is a sequence of integers from $$$1$$$ to $$$n$$$ of length $$$n$$$ containing each number exactly once. You are given a permutation $$$[a_1,a_2,\ldots,a_n]$$$. For each $$$i$$$, solve the following problem independently:
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^5$$$). Description of the test cases follows.
The first line of each test case contains an integer $$$n$$$ ($$$1\le n\le 5\cdot 10^5$$$).
The second line of each test case contains $$$n$$$ distinct integers $$$a_1,\ldots,a_n$$$ ($$$1\le a_i\le n$$$).
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^6$$$.
For each test case, print one line containing $$$n$$$ integers. The $$$i$$$-th integer should be the answer when erasing $$$a_i$$$.
41133 1 254 2 1 5 388 1 4 6 7 3 5 2
0 4 7 5 19 21 27 17 19 79 100 72 68 67 80 73 80
In the second test case, $$$a=[3,1,2]$$$.
Name |
---|