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

16799번 - Optimal alpha beta pruning 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB944100.000%

문제

Fox Ciel is developing an artificial intelligence (AI) for a game. This game is described as a game tree T with n vertices. Each node in the game has an evaluation value which shows how good a situation is. This value is the same as maximum value of child nodes’ values multiplied by -1. Values on leaf nodes are evaluated with Ciel’s special function -- which is a bit heavy. So, she will use alpha-beta pruning for getting root node’s evaluation value to decrease the number of leaf nodes to be calculated.

By the way, changing evaluation order of child nodes affects the number of calculation on the leaf nodes. Therefore, Ciel wants to know the minimum and maximum number of times to calculate in leaf nodes when she could evaluate child node in arbitrary order. She asked you to calculate minimum evaluation number of times and maximum evaluation number of times in leaf nodes.

Ciel uses following algotithm:

function negamax(node, α, β)
 if node is a terminal node
 return value of leaf node
 else
 foreach child of node
 val := -negamax(child, -β, -α)
 if val >= β
 return val
 if val > α
 α := val
 return α

[NOTE] negamax algorithm

입력

Input follows following format:

n
p1 p2 ... pn
k1 t11 t12 ... t1k
:
:
kn tn1 tn2 ... tnk

The first line contains an integer n, which means the number of vertices in game tree T. The second line contains n integers pi, which means the evaluation value of vertex i. Then, next n lines which contain the information of game tree T. ki is the number of child nodes of vertex i, and tij is the indices of the child node of vertex i.

Input follows following constraints:

  • 2 ≤ n ≤ 100
  • -10,000 ≤ pi ≤ 10,000
  • 0 ≤ ki ≤ 5
  • 2 ≤ tij ≤ n
  • Index of root node is 1.
  • Evaluation value except leaf node is always 0. This does not mean the evaluation values of non-leaf nodes are 0. You have to calculate them if necessary.
  • Leaf node sometimes have evaluation value of 0.
  • Game tree T is tree structure.

출력

Print the minimum evaluation number of times and the maximum evaluation number of times in leaf node. Please separated by whitespace between minimum and maximum.

minimum maximum

제한

예제 입력 1

3
0 1 1
2 2 3
0
0

예제 출력 1

2 2

예제 입력 2

8
0 0 100 100 0 -100 -100 -100
2 2 5
2 3 4
0
0
3 6 7 8
0
0
0

예제 출력 2

3 5

예제 입력 3

8
0 0 100 100 0 100 100 100
2 2 5
2 3 4
0
0
3 6 7 8
0
0
0

예제 출력 3

3 4

예제 입력 4

19
0 100 0 100 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10
2 2 3
0
2 4 5
0
3 6 7 8
3 9 10 11
3 12 13 14
3 15 16 17
2 18 19
0
0
0
0
0
0
0
0
0
0

예제 출력 4

7 12

힌트

출처

Contest > ICPC Japanese Alumni Group > JAG Summer Camp > JAG Summer Camp 2013 Day 4 E번

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

출처

대학교 대회

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

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