题库练习 Red-Blue Shuffle
← 上一题 下一题 →

A13871 | Red-Blue Shuffle

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

There are $n$ cards numbered $1, \ldots, n$ . The card $i$ has a red digit $r_i$ and a blue digit $b_i$ written on it.

We arrange all $n$ cards in random order from left to right, with all permutations of $1, \ldots, n$ having the same probability. We then read all red digits on the cards from left to right, and obtain an integer $R$ . In the same way, we read all blue digits and obtain an integer $B$ . When reading a number, leading zeros can be ignored. If all digits in a number are zeros, then the number is equal to $0$ . Below is an illustration of a possible rearrangement of three cards, and how $R$ and $B$ can be found.

![](/uploads/acgo/image/441da67663b7f865_8317c7ead1b0.jpeg)Two players, Red and Blue, are involved in a bet. Red bets that after the shuffle $R > B$ , and Blue bets that $R < B$ . If in the end $R = B$ , 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.

输入格式

The first line contains a single integer $T$ ( $1 \leq T \leq 100$ ) — the number of test cases.

Descriptions of $T$ test cases follow. Each test case description starts with a line containing a single integer $n$ ( $1 \leq n \leq 1000$ ) — the number of cards.

The following line contains a string of $n$ digits $r_1, \ldots, r_n$ — red digits on cards $1, \ldots, n$ respectively.

The following line contains a string of $n$ digits $b_1, \ldots, b_n$ — blue digits on cards $1, \ldots, n$ respectively.

Note that digits in the same line are not separated with any delimiters.

输出格式

Print $T$ 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.

输入输出样例

输入 #1
3
3
777
111
3
314
159
5
09281
09281
输出 #1
RED
BLUE
EQUAL
C++ 编辑器
输入
输出