P24990 [AtCoder] [ARC048B] Playing Rock-Paper-Scissors at AtCoder
普及+
题目描述

Problem Description

An AtCoder Rock-Paper-Scissors tournament is being held. AtCoder Rock-Paper-Scissors is a game played between two people, as follows:

  • First, both players independently choose one of rock, scissors, or paper.
  • If the ratings of the two players are not equal, the player with the higher rating is declared the winner.
  • If the ratings of the two players are equal and they chose different hands, the winner is determined by the standard rules of Rock-Paper-Scissors.
  • If the ratings of the two players are equal and they chose the same hand, the result is a draw.

There are $ N $ participants in the tournament. During the tournament, each participant continues to play the same hand, and their ratings do not change.

Each participant plays exactly one AtCoder Rock-Paper-Scissors match against every other participant.

Given the rating and chosen hand of each participant, determine the final record (number of wins, losses, and draws) for each participant at the end of the tournament.

In standard Rock-Paper-Scissors, rock beats scissors, scissors beat paper, and paper beats rock.

Input Format

The input is given from the standard input in the following format:

$ N $ $ R_1 $ $ H_1 $ . . . $ R_N $ $ H_N $

  • The first line contains an integer $N(1\ ≦\ N\ ≦\ 100000)$.
  • The following $ N $ lines contain integers $R_i,\ H_i(1\ ≦\ R_i\ ≦\ 100000,\ 1\ ≦\ H_i\ ≦\ 3)$ separated by spaces, representing the information for the $ i $-th participant. $ R_i $ is the rating of the $ i $-th participant, and $ H_i $ is the hand they play: $ H_i=1 $ for rock, $ H_i=2 $ for scissors, and $ H_i=3 $ for paper.

Output Format

  • The output consists of $ N $ lines.
  • The $ i $-th line should contain three integers representing the number of wins, losses, and draws for the $ i $-th participant, separated by spaces.

Do not forget to add a newline at the end of the output.

Sample Input and Output

Sample Input #1

6
2 1
2 2
3 2
5 3
2 2
3 3

Sample Output #1

2 3 0
0 4 1
4 1 0
5 0 0
0 4 1
3 2 0

Sample Input #2

2
1999 3
2000 1

Sample Output #2

0 1 0
1 0 0

Sample Input #3

8
3200 2
2800 3
2800 2
2700 1
2800 2
3200 1
2700 1
3200 3

Sample Output #3

6 1 0
2 5 0
3 3 1
0 6 1
3 3 1
6 1 0
0 6 1
6 1 0

Notes/Hints

Sample Explanation 1

The results table looks like this: Figure 1: Results Table

Sample Explanation 2

There is no mercy.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
6 2 1 2 2 3 2 5 3 2 2 3 3
样例输出
2 3 0 0 4 1 4 1 0 5 0 0 0 4 1 3 2 0