Hide

Problem F
Letter Optimization

Languages en ja sv

The programming olympiad committee, composed of N people, is going to send out envelopes with posters for the qualifier competition to all schools. To make the process faster, they have split up the tasks that need to be done. The tasks include writing addresses, putting on stamps, inserting the posters, and closing the envelopes. When a person finishes an envelope, it is sent to another person. It’s not going as fast as they had hoped, so they wonder which people could be working faster.

Each person p has their own maximum production speed of Mp envelopes per second. If we let Ip be the number of envelopes are sent to person p per second, and let Up be the number of envelopes that are finished per second, then Up=min(Ip,Mp). A person also cannot finish more than Mp letters per second, even if they get more to work with. Therefore, each person has a number of people to whom they send their finished envelopes. Person p is not required to send the same number of envelopes to each person, but each person receives a certain percentage of the envelopes p sends. The people to whom no one sends any envelopes, and are therefore at the beginning of the production line, have Ip=, and therefore Up=Mp (they have an infinite pile of envelopes to work from). Certain people do not send envelopes any further; they just put them into a pile beside them when they are done.

Which people have the property that Up=Mp, that is, they are working at their maximum production speed?

Input

The first line contains an integer 1N105, the number of people. The next N lines describe the people. Line i begins with the integer Mi, the maximum production speed of person i (1Mi105). After that comes an integer k, and then k pairs of integers j w, which means that person i sends w percent of their envelopes to person j (1w100, 1jN,ij). No j can appear more than once per line, and the sum of the w values on each line is 100, unless k=0.

Let S be the sum of all k. Then 0S105.

The production chain is designed in such a way that no person can get back a letter they have already worked on.

Output

Print a line with all i that fulfill Up=Mp, in increasing order.

It’s guaranteed that if Up=Mp, then this will be true with a margin, more specifically IpMp>104.

If, on the other hand, UpMp, then there is a margin in the other direction: MpIp>104.

Points

Your solution will be tested on several test case groups. To get the points for a group, it must pass all the test cases in the group.

Group

Point value

Bounds

1

12

Each person sends letters to at most one person (i.e. k1) and receives letters from at most one person.

2

17

Each person receives letters from exactly one other person, except person 1 who doesn’t receive any letters.

3

21

If person i sends to person j, then i<j.

4

25

N,S10

5

25

No additional constraints.

Explanation of test case

Here are three graphs that represent the three example cases. Each person is represented by a node. On each edge, the number of envelopes sent is written in the unit "ps", envelopes per second.

Note that in test case group 1, only sample case 1 could occur, in test case group 2 only example case 2, and in test case group 3 only example case 3.

In test case groups 4 and 5, all three example cases could occur.

\includegraphics[width=0.8\textwidth ]{sample1}
Figure 1: Sample 1
\includegraphics[width=0.8\textwidth ]{sample2}
Figure 2: Sample 2
\includegraphics[width=0.8\textwidth ]{sample3}
Figure 3: Sample 3
Sample Input 1 Sample Output 1
8
7 0
10 1 6 100
8 1 4 100
9 1 1 100
11 0
12 1 5 100
10 1 3 100
5 0
1 2 3 7 8
Sample Input 2 Sample Output 2
10
16 3 2 50 4 25 6 25
9 2 9 75 5 25
2 1 8 100
5 0
1 0
2 2 3 90 7 10
1 0
1 0
5 1 10 100
6 0
1 5 6 8 9
Sample Input 3 Sample Output 3
6
10 3 2 25 3 25 4 50
1000 1 5 100
1000 1 5 100
1000 1 6 100
1 1 6 100
1000 0
1 5
Hide

Please log in to submit a solution to this problem

Log in