P27614 [洛谷] [Language Month Competition 202405] Xiao S vs. Xiao Q
普及-
题目描述

Problem Description

Xiao S and Xiao Q lead their respective teams onto the battlefield, where a fierce battle is imminent. As an audience member, you are eager to predict the outcome of the battle.

The battle rules are as follows: Each team has $n$ members, and the competition consists of $n$ rounds. In the $i$-th round, both teams will send out their $i$-th member.

Let $a_i$ represent the combat power of the $i$-th member of Xiao S's team, and $b_i$ represent the combat power of the $i$-th member of Xiao Q's team. For the $i$-th round, the team whose member has the higher combat power wins. If both members have the same combat power, the round ends in a draw.

The final outcome is determined as follows:

  • If Xiao S's team wins more rounds than Xiao Q's team, Xiao S wins the overall battle.
  • If Xiao S's team wins fewer rounds than Xiao Q's team, Xiao Q wins the overall battle.
  • If Xiao S's team wins the same number of rounds as Xiao Q's team, the result is a tie.

Please output the number of rounds won by Xiao S's team and Xiao Q's team, and determine which team wins the overall battle or if it results in a tie.

Input Format

The first line contains a positive integer $n$, representing the number of members in each team and the number of rounds.
The second line contains $n$ non-negative integers $a_i$, representing the combat power of Xiao S's team members.
The third line contains $n$ non-negative integers $b_i$, representing the combat power of Xiao Q's team members.

Output Format

The first line should output two non-negative integers, representing the number of rounds won by Xiao S's team and Xiao Q's team, respectively.
The second line should output a string. If Xiao S's team wins, output S; if Xiao Q's team wins, output Q; otherwise, output Tie.

Sample Input and Output

Sample Input #1

3
2 3 1
1 2 3

Sample Output #1

2 1
S

Sample Input #2

5
1 1 1 2 3
1 1 1 3 3

Sample Output #2

0 1
Q

Sample Input #3

4
2 3 1 6
1 4 2 5

Sample Output #3

2 2
Tie

Notes

Sample 1 Explanation

The winners of the three rounds are: Xiao S, Xiao S, Xiao Q. Therefore, Xiao S's team wins 2 rounds, Xiao Q's team wins 1 round, and Xiao S wins the overall battle.

Sample 2 Explanation

Except for the 4th round where Xiao Q wins, all other rounds are draws. Thus, Xiao S's team wins 0 rounds, Xiao Q's team wins 1 round, and Xiao Q wins the overall battle.

Sample 3 Explanation

The winners of the four rounds are: Xiao S, Xiao Q, Xiao Q, Xiao S. Therefore, Xiao S's team wins 2 rounds, Xiao Q's team wins 2 rounds, and the overall result is a tie.

Data Range

For the first $30\%$ of the data, it is guaranteed that the total scores of both teams are equal.
For the next $30\%$ of the data, it is guaranteed that Xiao S's team wins fewer rounds than Xiao Q's team.
For $100\%$ of the data, it is guaranteed that $1 \leq n \leq 10^6, 0 \leq a_i, b_i \leq 10^9$.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 2 3 1 1 2 3
样例输出
2 1 S