欢迎光临散文网 会员登陆 & 注册

CF 1774A - Add Plus Minus Sign

2023-08-18 14:22 作者:您是打尖儿还是住店呢  | 我要投稿

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。她想在所有连续位置对之间添加 + 和 −,以使结果表达式的绝对值尽可能小。 你能帮助她吗?


输入

第一行包含一个整数 t (1≤t≤2000) – 测试用例的数量。 测试用例的描述如下。

每个测试用例的第一行包含一个整数 n (2≤n≤100) — a 的长度。

每个测试用例的第二行包含一个长度为n的字符串a,仅由0和1组成。

输出

对于每个测试用例,在单独的行上输出一个长度为 n−1 的字符串,其中包含 - 和 +。 如果存在多个产生最小可能绝对值的符号分配,则接受其中任何一个。

例子

------------------------

目的是和最小,当是奇数的时候,可以加,当时偶数的时候就减,即可;

下面是代码;


CF 1774A - Add Plus Minus Sign的评论 (共 条)

分享到微博请遵守国家法律