All submissions for this problem are available.
Read problems statements in Mandarin Chinese and Russian as well.
N Soldiers are lined up for a memory test. They are numbered from 0 to N-1 from left to right.
In the test, there are M rounds. In each round, Captain selects one position. Soldier at that position will be numbered 0. All the soldiers to the right of selected position will be numbered one greater than the soldier to his left. All the soldiers to the left of selected position will be numbered one greater than the soldier to his right. eg. if N = 6 and selected position is 3, then the numbering will be [3, 2, 1, 0, 1, 2].
After M rounds, Captain asked each soldier to shout out the greatest number he was assigned during the M rounds. In order to check the correctness, Captain asked you to produce the correct values for each soldier (That is the correct value each soldier should shout out).
The first line of the input contains an integer T denoting the number of test cases. First line of each test case contains two integers, N and M. Second line of each test case contains M integers, the positions selected by Captain, in that order.
For each test case, output one line with N space separated integers.
- 1 ≤ T ≤ 10^4
- 1 ≤ N ≤ 10^5
- 1 ≤ M ≤ 10^5
- 1 ≤ Sum of N over all testcases ≤ 10^5
- 1 ≤ Sum of M over all testcases ≤ 10^5
- 0 ≤ Positions selected by captain ≤ N-1
Input 2 4 1 1 6 2 2 3 Output 1 0 1 2 3 2 1 1 2 3
|Tags||anudeep2011, cook51, simple|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.