CF 1774A - Add Plus Minus Sign
AquaMoon has a string a consisting of only 0 and 1. She wants to add + and ? between all pairs of consecutive positions to make the absolute value of the resulting expression as small as possible. Can you help her?
Input
The first line contains a single integer t (1≤t≤2000)? – the number of test cases. The description of test cases follows.
The first line of each test case contains a single integer n (2≤n≤100) — the length of a.
The second line of each test case contains a string a of length n, consisting of only 0 and 1.
Output
For each test case, output a string of length n?1 consisting of ? and + on a separate line. If there is more than one assignment of signs that produces the smallest possible absolute value, any of them is accepted.
Example
--------------------------------------
AquaMoon 有一個僅由 0 和 1 組成的字符串 a。她想在所有連續(xù)位置對之間添加 + 和 ?,以使結(jié)果表達(dá)式的絕對值盡可能小。 你能幫助她嗎?
輸入
第一行包含一個整數(shù) t (1≤t≤2000) – 測試用例的數(shù)量。 測試用例的描述如下。
每個測試用例的第一行包含一個整數(shù) n (2≤n≤100) — a 的長度。
每個測試用例的第二行包含一個長度為n的字符串a(chǎn),僅由0和1組成。
輸出
對于每個測試用例,在單獨的行上輸出一個長度為 n?1 的字符串,其中包含 - 和 +。 如果存在多個產(chǎn)生最小可能絕對值的符號分配,則接受其中任何一個。
例子
------------------------
目的是和最小,當(dāng)是奇數(shù)的時候,可以加,當(dāng)時偶數(shù)的時候就減,即可;
下面是代碼;