ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1218. Episode N-th: The Jedi Tournament

Another approach
Posted by andreyDagger 11 Nov 2021 22:35
I see many people solved this with graph algorithms, there is also greedy approach.

Let's build graph: u->v, if jedi u is winning v.
You are doing n iterations, on every iteration you check, can current Jedi win, or not. There is greedy strategy to check this. You can eliminating enemies in order of the number of incoming edges. The fewer edges lead to a Jedi, the earlier we should eliminate him

Edited by author 11.11.2021 22:35

Edited by author 11.11.2021 22:35

Edited by author 11.11.2021 22:36