|
||||||||||
AraBellaCTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 400 Accepted Submission(s): 128 Problem Description 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` Input 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$. Output 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) Sample Input
Sample Output
Source | ||||||||||
|