From Zero to Infinity

All submissions for this problem are available.
### Read problem statements in [Hindi](http://www.codechef.com/download/translated/NOV19/hindi/WEIRDO.pdf), [Bengali](http://www.codechef.com/download/translated/NOV19/bengali/WEIRDO.pdf), [Mandarin Chinese](http://www.codechef.com/download/translated/NOV19/mandarin/WEIRDO.pdf), [Russian](http://www.codechef.com/download/translated/NOV19/russian/WEIRDO.pdf), and [Vietnamese](http://www.codechef.com/download/translated/NOV19/vietnamese/WEIRDO.pdf) as well. Alice and Bob created $N$ and $M$ recipes, respectively ($N, M \ge 1$), and submitted them to Chef for evaluation. Each recipe is represented by a string containing only lowercase English letters. Let's denote Alice's recipes by $A_1, A_2, \ldots, A_N$ and Bob's recipes by $B_1, B_2, \ldots, B_M$. Accidentally, Chef mixed up those recipes ― now, he has $L = N+M$ recipes in a sequence $S_1, S_2, \ldots, S_L$. Thankfully, the recipes created by Alice and Bob are distinguishable from each other. It is wellknown that for each recipe $s$ created by Alice, the following property holds, and for each recipe created by Bob, it does not hold: For each $1 \le l \lt r \le s$, the substring $s_l, s_{l+1}, \ldots, s_r$ contains at least as many vowels as consonants. The letters 'a', 'e', 'i', 'o', 'u' are vowels, while the other letters are consonants. The score of a candidate who made $K$ recipes is calculated as the product of $\frac{x_c}{fx_c^K}$ for all letters $c$ that occur in at least one of these recipes; here, $x_c$ is the number of recipes which contain the letter $c$ and $fx_c$ is the total number of occurrences of this letter in all $K$ recipes. Let's denote the scores of Alice and Bob by $sc_A$ and $sc_B$ respectively. Chef wants to know their ratio $sc_A/sc_B$. We know that Chef is a legendary cook, but he is not very good at calculating, so he is asking you to find that number. ### Input  The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.  The first line of each test case contains a single integer $L$.  $L$ lines follow. For each valid $i$, the $i$th of these lines contains a single string $S_i$. ### Output For each test case, if the ratio of scores exceeds $10^7$, print a single line containing the string `"Infinity"` (without quotes); otherwise, print a single line containing one real number $sc_A/sc_B$. Your answer will be considered correct if its absolute or relative error does not exceed $10^{6}$. It is guaranteed that $sc_A/sc_B$ does not lie in the range $10^7 \pm 10$. ### Constraints  $1 \le T \le 10^5$  $2 \le L \le 10^5$  $2 \le S_i \le 10^5$ for each valid $i$  for each valid $i$, $S_i$ contains only lowercase English letters  the sum of $S_1 + S_2 + \ldots + S_L$ over all test cases does not exceed $10^7$ ### Subtasks **Subtask #1 (25 points):**  $L \le 10$  $S_i \le 10$ for each valid $i$ **Subtask #2 (75 points):** original constraints ### Example Input ``` 2 4 aba abc bab aac 3 aba baab abc ``` ### Example Output ``` 1.1250000 0.0277778 ``` ### Explanation **Example case 1:** The recipes "aba" and "aac" are created by Alice, while the recipes "abc" and "bab" are created by Bob. The scores are:  $sc_A = \frac{x_a}{fx_a^N} \cdot \frac{x_b}{fx_b^N} \cdot \frac{x_c}{fx_c^N} = \frac{2}{4^2} \cdot \frac{1}{1^2} \cdot \frac{1}{1^2} = \frac{1}{8}$  $sc_B = \frac{x_a}{fx_a^M} \cdot \frac{x_b}{fx_b^M} \cdot \frac{x_c}{fx_c^M} = \frac{2}{2^2} \cdot \frac{2}{3^2} \cdot \frac{1}{1^2} = \frac{1}{9}$  $\frac{sc_A}{sc_B} = \frac{1/8}{1/9} = 1.125$Author:  akil_av17 
Editorial  https://discuss.codechef.com/problems/WEIRDO 
Tags  akil_av17, challenge, logarithm, nov19, watcher 
Date Added:  1092019 
Time Limit:  1.5 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions