#P4589. [TJOI2018] 智力竞赛
[TJOI2018] 智力竞赛
Description
Xiaodou signed up for an intelligence contest. He brought good friends as his cheering group to take part in the contest together. The rules are as follows.
There are problems in total. Each person has chance to answer questions. In each attempt, they choose one problem to answer. After answering correctly, they may continue to answer the subsequent problems of this problem, until they answer a problem incorrectly or there is no subsequent problem.
Each problem has a value. At the end of the contest, the reward value that a participant gets is equal to the minimum value among the problems that were not answered by this participant and his cheering group.
Now we know that Xiaodou and his cheering group are very strong and can solve all the problems in this contest.
Xiaodou wants to know, given the information about the problems and their subsequent problems, what is the maximum value he can obtain.
Input Format
The first line contains two integers . ().
The next lines describe the problems. Line gives the information of problem , in the form , where is the value of this problem, is the number of subsequent problems of this problem, and are the indices of these subsequent problems.
Output Format
If all problems can be answered correctly, output AK. Otherwise, output the maximum reward value that Xiaodou can obtain.
1 3
1 0
2 1 3
3 0
AK
1 6
1 2 2 3
2 1 4
3 1 4
4 1 6
5 0
6 0
5
Hint
For of the testdata, .
For of the testdata, .
For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号