Skip to content

Commit

Permalink
Update ac-GameOnTree.mdx
Browse files Browse the repository at this point in the history
  • Loading branch information
SansPapyrus683 authored Nov 4, 2024
1 parent a9a47de commit 074fedb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion solutions/advanced/ac-GameOnTree.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ author: Aakash Gokhale

[Official Editorial (Japanese)](https://atcoder.jp/contests/agc017/editorial)

## Explanation

Since the game in the problem seems similar to Nim, let's try to use Sprague-Grundy numbers.

To solve the problem, for a certain root with subtrees, $s_1, s_2, ..., s_k$, we can try to convert all these subtrees into a stack of some size.
Expand Down Expand Up @@ -39,6 +41,7 @@ This makes sense because whichever edge that Alice chooses, Bob can choose the o
#include <functional>
#include <iostream>
#include <vector>

using namespace std;

int main() {
Expand Down Expand Up @@ -74,7 +77,10 @@ int main() {
<PySection>

<Warning>
Submit the solution in PyPy to avoid MLE.

The below solution only works when you submit with PyPy.
Submitting with normal Python will result in MLE.

</Warning>

```py
Expand Down

0 comments on commit 074fedb

Please sign in to comment.