Logo
(追記) (追記ここまで)

21140번 - Exciting Tournament 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB24111157.895%

문제

A group of players compete in a no-holds-barred tournament.

Each player has a unique skill level (represented as an integer). In each game, two players play, and the player of higher skill level wins. The player of lower skill level is immediately eliminated from the tournament! The tournament continues until there is only one player left.

Due to scheduling constraints, each player has a limit on the maximum number of games they can play. Interestingly, this is the only constraint that the tournament bracket needs to meet. In other words, the bracket may not necessarily have the shape of a balanced binary tree, as long as every player plays at most their maximum number of games before getting eliminated or winning the entire tournament.

As a tournament organizer, you are free to choose any valid bracket. Given the list of participants, you wonder how exciting (or not exciting) the tournament can get. Concretely, the excitement of a game is defined as the bitwise XOR of the two players’ skill levels. The excitement of the tournament is simply the sum of the excitement of each game.

Compute the minimum and maximum possible excitement values of the entire tournament.

입력

The first line of input contains a single integer $n$ (3ドル \le n \le 100$), which is the number of players in the tournament.

Each of the next $n$ lines contains two integers $s$ (0ドル \le s < 2^{30}$) and $g$ (2ドル \le g < n$). Each line describes a single player; $s$ is the skill level of the player, and the $g$ is the limit on the number of games that player can play.

출력

Output two space-separated integers on a single line, which are the minimum and maximum possible excitement values of the entire tournament, minimum first.

제한

예제 입력 1

4
41 2
13 2
36 3
17 3

예제 출력 1

94 110

예제 입력 2

6
66 5
628 4
216 5
78 4
230 5
74 3

예제 출력 2

882 2650

힌트

출처

ICPC > Regionals > North America > Southeast USA Regional > 2020 Southeast USA Regional Programming Contest G번

ICPC > Regionals > North America > Mid-Central Regional > 2020 Mid-Central Regional Programming Contest G번

ICPC > Regionals > North America > Pacific Northwest Regional > 2020 ICPC Pacific Northwest Region > Division 1 N번

ICPC > Regionals > North America > Mid-Atlantic Regional > 2020 Mid-Atlantic USA Regional Contest E번

ICPC > Regionals > North America > South Central USA Regional > 2020 South Central USA Regional Contest G번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /