CF1536C Diluc and Kaeya

题目描述

给你一个字符串 $S$,其中只包含 'K' 或 'D' 两种字符,要求划分这个字符串使得各部分的 $n(D):n(K)$ 相同,其中 $n(D)$ 表示 $S$ 中字符 'D' 出现的个数,最大化划分后形成的组数。 求出 $S$ 的所有前缀中的上述答案。

输入格式

第一行一个整数 $T$,代表测试组数。 接下来每一组第一行一个整数 $n$,代表字符串 $S$ 的长度,第二行一个字符串 $S$。

输出格式

一共输出 $T$ 行,对于每组数据,输出 $S$ 的所有前缀的答案。 --by ¶凉笙

说明/提示

For the first test case, there is no way to partition 'D' or 'DDK' into more than one block with equal ratios of numbers of 'D' and 'K', while you can split 'DD' into 'D' and 'D'. For the second test case, you can split each prefix of length $ i $ into $ i $ blocks 'D'.