当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6387:AraBellaC

题目描述
Princess Arabella loves the letter `C`, which earned her the epithet `ArraBellaC`. She would like to endeavor to construct a periodic string with length $n(n \leq 20000)$ to spare her tedious time. In every period of the string, the substring begins with dozens of `A`s and ends with dozens of `C`s, and dozens of `B`s are inserted between them, and the number of `A`, `B`, `C` is $a$, $b$, $c$.(For example, if $a=1$, $b=1$, $c=2$ then one of the period of the string is `ABCC`, and the periodic string is `ABCCABCC……`).Note that in the last period of the string, the substring can be incomplete and the last few letters of the period can be cut down.

And now, Arabella has constructed a periodic string, she want to give you a question: if she tells you the character is $C_i(C_i \in \{A, B, C\})$ in the $X_i(X_i \leq 10000)$ , then could you tell her the value of $a,b,c$? If there are multiple answers, please find the lexicographically smallest answer. If you can’t find a valid answer, please print `NO`
输入解释
The first line gives an integer $T(1\leq T \leq 40)$ , which indicates the number of cases in the input.$\\$
The first line of every case contains only one integer $m(1 \leq m \leq 5000)$, which means the number of characters AraBella told you.$\\$
A number $X_i(1\leq X_i\leq 10000)$ and a letter $C_i$ are given in the following m lines, which means the position $X_i$ in the string with letter $C_i$.
输出解释
Print $a, b, c$ in order. If there are multiple answers, please find the lexicographically smallest answer. If you can’t find a valid answer, please print `NO`.(It is gratuated that $0 < a, b, c$, and please forget my poor Yinglish)
输入样例
2
3
1 A
2 B
3 C
4
1 A
2 C
3 B
4 C
输出样例
1 1 1
NO
来自杭电HDUOJ的附加信息
Recommend chendu

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6387

最后修改于 2020-10-25T23:30:54+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 65536/65536K(Java/Others)