欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1459A.Red-Blue Shuffle
Red-Blue Shuffle
There are cards numbered . The card has a red digit and a blue digit written on it.
We arrange all cards in random order from left to right, with all permutations of having the same probability. We then read all red digits on the cards from left to right, and obtain an integer . In the same way, we read all blue digits and obtain an integer . When reading a number, leading zeros can be ignored. If all digits in a number are zeros, then the number is equal to . Below is an illustration of a possible rearrangement of three cards, and how and can be found.

Two players, Red and Blue, are involved in a bet. Red bets that after the shuffle , and Blue bets that . If in the end , the bet results in a draw, and neither player wins.
Determine, which of the two players is more likely (has higher probability) to win the bet, or that their chances are equal. Refer to the Note section for a formal discussion of comparing probabilities.
Input
The first line contains a single integer () — the number of test cases.
Descriptions of test cases follow. Each test case description starts with a line containing a single integer () — the number of cards.
The following line contains a string of digits — red digits on cards respectively.
The following line contains a string of digits — blue digits on cards respectively.
Note that digits in the same line are not separated with any delimiters.
Output
Print answers for the test cases in order, one per line.
If Red has a strictly higher change to win, print "RED".
If Blue has a strictly higher change to win, print "BLUE".
If both players are equally likely to win, print "EQUAL".
Note that all answers are case-sensitive.
Note
Formally, let be the number of permutations of cards such that the resulting numbers and satisfy . Similarly, let be the number of permutations such that . If , you should print "RED". If , you should print "BLUE". If , print "EQUAL".
In the first sample case, and 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:
- order : ;
- order : ;
- order : ;
- order : ;
- order : ;
- order : .
Since is more frequent, the answer is "BLUE".
In the third sample case, regardless of the card order, thus the bet is always a draw, and both Red and Blue have zero chance to win.
Samples
3
3
777
111
3
314
159
5
09281
09281
RED
BLUE
EQUAL
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |