CF1459A Red-Blue Shuffle

题目描述

### 题意翻译 有 $n$ 张卡,第 $i$ 张卡上有一个红色的数码 $R_i$ 和一个蓝色的数码 $B_i$ 。如果将牌随机洗好后从左到右摆放(即`random_shuffle`)后,令红色的数码从左到右连起来**严格大于**蓝色的数码概率为 $r$ ;红色的数码连起来**严格小于**蓝色的数码为 $b$ 。 如果 $r>b$ ,输出`RED`; 如果 $r

输入格式

第一行输入 $T$ ,表示数据组数。 对于每一个数据,第一行输入 $n$ ,表示卡的个数。 接下来输入两个字符串 $R, B$ ,其中 $R_i, B_i$ 分别表示第 $i$ 张卡的红色数码、蓝色数码。

输出格式

对于每一组数据输出一行字符串,表示该组数据的答案。

说明/提示

Formally, let $ n_R $ be the number of permutations of cards $ 1, \ldots, n $ such that the resulting numbers $ R $ and $ B $ satisfy $ R > B $ . Similarly, let $ n_B $ be the number of permutations such that $ R < B $ . If $ n_R > n_B $ , you should print "RED". If $ n_R < n_B $ , you should print "BLUE". If $ n_R = n_B $ , print "EQUAL". In the first sample case, $ R = 777 $ and $ B = 111 $ regardless of the card order, thus Red always wins. In the second sample case, there are two card orders when Red wins, and four card orders when Blue wins: 4. order $ 1, 2, 3 $ : $ 314 > 159 $ ; 5. order $ 1, 3, 2 $ : $ 341 > 195 $ ; 6. order $ 2, 1, 3 $ : $ 134 < 519 $ ; 7. order $ 2, 3, 1 $ : $ 143 < 591 $ ; 8. order $ 3, 1, 2 $ : $ 431 < 915 $ ; 9. order $ 3, 2, 1 $ : $ 413 < 951 $ . Since $ R < B $ is more frequent, the answer is "BLUE". In the third sample case, $ R = B $ regardless of the card order, thus the bet is always a draw, and both Red and Blue have zero chance to win.