people people numbered from 0 to people - 1. Person 0 learns some news and, at time 0, tells it to person first_friend.
After that, people make calls: calls[i] = [x, y, t] means x and y talk at time t. If at least one of them knows the news when they talk, both know it afterwards. A person may take part in several calls at the same moment.
The news travels instantly: someone who learns it at time t can pass it on in other calls happening at that same time t.
Return the numbers of everyone who knows the news once all calls are over, in any order.people=5, calls=[[1, 4, 3], [2, 3, 1], [4, 2, 6]], first_friend=1 → [0, 1, 2, 4]
At first only 0 and 1 know. At time 1, people 2 and 3 talk, but neither knows yet. At time 3, person 1 tells 4, and at time 6, person 4 tells 2. Person 3 talked to 2 before 2 learned the news, so 3 never hears it.
people=4, calls=[[2, 3, 5], [0, 2, 5]], first_friend=1 → [0, 1, 2, 3]
Both calls happen at time 5. Person 0 tells 2, who passes it on to 3 within the same moment.
people=3, calls=[[1, 2, 2]], first_friend=2 → [0, 1, 2]
people=5, calls=[[1, 4, 3], [2, 3, 1], [4, 2, 6]], first_friend=1
[0, 1, 2, 4]
Run checks the first 3 tests in your browser. Submit checks all 83 tests on the server, hidden ones included.