Skip to content

List: Game on treeOffshoresLawn MowerParabola IndependenceTicket Hoarding

Game on tree

Thanks to t=1, just a dfs problem. The condition used for checking the winner is easy: when there exists a even length, then Hermione win, otherwise Ron win. What deserves to learn is code. First we find one leave and begin with this. And dfs.

Offshores

Lawn Mower

Just a math poblem.

Parabola Independence

Ticket Hoarding

Greedy. Actually, these exists a balance same as Offshores. We can observe that no matter which one choose firstly , the cost always add 1. So we greedily begin with first element after sorting. By the way, notice the range of int, so we should use long long here.