yosupo
November 18, 2016
2.7k

# Grundy

## yosupo

November 18, 2016

## Transcript

7. ### O((N+M)^K)ʂʁ N=M=5000ͱͯ͠(N+M)^K͸ʁ K=1 → 10000 K=2 → 1,000,000,000 K=3 →

10,000,000,000,000 K=100 → 10^400

12. ### (άϥϑA + άϥϑX)ͷউഊͱ(άϥϑB + άϥϑX)ͷউഊ ͕ɺXʹ͔͔ΘΒͣ౳͍࣌͠ɺάϥϑA,BΛʮຊ࣭తʹ౳͠ ͍ʯͱ͢Δ (ޙखউͪ+ޙखউͪ)ͱ(ޙखউͪ+ઌखউͪ)͸Ұҙʹఆ·Δ ͷͰɺޙखউͪͲ͏͠͸ʮຊ࣭తʹ౳͍͠ʯ ͳͷͰɺઌखউͪͲ͏͠΋ʮຊ࣭తʹ౳͍͠ʯͷͰ͸ʁͱ

Ծఆࣦͯ͠ഊͨ͠ͷ͕ࠓͷঢ়ଶ ઌखউͪͷάϥϑ͸1छྨʹ·ͱΊΔ͜ͱ͸Ͱ͖ͳ͍ʂ

22. ### ΄΅׬શDAG ௖఺਺{a, b, c, …}ʹߦ͚Δͱ͢Δͱɺ௖఺਺=ʮ{a, b, c, …}ʹ ग़ͯ͜ͳ͍࠷খͷਖ਼੔਺ʯͷ׬શDAGͱຊ࣭తʹ౳͍͠ ྫ͑͹{1,

3, 4, 5}ʹߦ͚ΔͳΒ͹௖఺਺=2 ͳ͔ͥͱ͍͏ͱɺ3,4,5ͷͲΕʹߦ͘ͷ΋ɺ࣍ͷखͰ૬खʹ2 ʹ໭͞ΕΔͷͰɺ༗རʹͳΕͳ͍

25. ### K=3 K=3ͷ৔߹͸ʁ ࠷ॳͷ۪௚ղΛࢥ͍ग़͢ͱɺෳ਺ݸͷάϥϑ͸1ݸͷάϥϑʹ·ͱΊΒΕΔ ͦͯ͠ɺk=2ͳΒ͹શͯͷάϥϑ͸׬શDAG΁มܗͰ͖Δ͜ͱΛ࢖͏ (άϥϑA + άϥϑB + άϥϑC)=  {άϥϑA

+ (άϥϑBͱάϥϑCΛ·ͱΊͨ΋ͷ)}=  (׬શDAG + άϥϑB + άϥϑC) Αͬͯk=2ͷ࣌ͱಉ͡نଇͰ׬શDAG΁มܗͯ͠Α͍
26. ### K=4 K=4ͷ৔߹͸ʁ (άϥϑA + άϥϑB + άϥϑC + άϥϑD)=  {άϥϑA+(άϥϑBͱάϥϑCͱάϥϑDΛ·ͱΊͨ΋ͷ)}=

(׬શDAG + άϥϑB + άϥϑC + άϥϑD)
27. ### ݁ہ (׬શDAG + ׬શDAG + … + ׬શDAG)ʹมܗͰ͖Δ ͜ͷඞউ൑ఆ͸ʁ(࣮͸NimήʔϜͱ͍͏༗໊ͳܗͷήʔϜʹͳ͍ͬͯΔ…) (׬શDAG

+ ׬શDAG + … + ׬શDAG)=  {(׬શDAGͱ׬શDAGΛ·ͱΊͨ΋ͷ) + (K-2ݸͷ׬શDAGΛ·ͱΊͨ΋ͷ)}=  ʹมܗͰ͖Δ ͱ͜ΖͰɺK=2ͳͷͰ(׬શDAGͱ׬શDAGΛ·ͱΊͨ΋ͷ)͸׬શDAG΁มܗͰ͖Δ ͭ·Γɺ(׬શDAGͱ׬શDAGΛ·ͱΊͨ΋ͷ)Λ׬શDAGʹมܗͰ͖ΔͱɺK-1ʹؼ ணͰ͖Δ
28. ### ׬શDAG + ׬શDAG (׬શDAGͱ׬શDAGΛ·ͱΊͨ΋ͷ)ͱ౳͍͠׬શDAGͷ ௖఺਺͸ʁ ࣮͸ɺ௖఺਺(a+1)ͱ(b+1)Λ·ͱΊΔͱɺ௖఺਺(a xor b)+1 ͱ౳͘͠ͳΔ(TODOઆ໌) ͭ·Γɺlevel

aͱlevel bΛ߹੒͢Δͱɺlevel (a xor b)ʹͳΔ (͜Ε͕0-indexedʹͨ͠ཧ༝)
29. ### ղ๏ ͱ͍͏͜ͱ͸ɺlevel a + b + …ͳΒ͹ɺlevel (a xor b

xor …) ͱ౳͍͠ ͜Ε͕0͔Ͳ͏͔൑ผ͢Ε͹౴͑ O(K(N+M))ʂ