2023.2.20 闲话

歌词:

XO (Eden Cover & Remake)
She's in love with the concept
As if we're all just how she imagined
Coz "we’re in love but just don’t know it yet", huh
Well, tell me how am I supposed to see the magic?
Coz I don’t believe in it no more
But I won’t tell her
Coz I always imagined
It’s easier if she thinks she won
So Imma let her, and she said
I don’t think I love you no more
You never seem to call me lately
Girl I don’t think you know me at all
Coz I never thought i'd have to say this
No I don’t love you, and I never did
Look at us burning down in flames for kicks but just know
I’m not singing for your XO
I’m just singing cause it's over, uh, yeah
Came and went like the summer time
Was that a sunset or sunrise
Looking back like where’d the time go
So much for trying to keep this moving slow
Coz I don’t believe in her no more
But I remember
How we talked shit like we knew what we wanted
I still remember what she said
I don’t think I love you no more
You never seem to call me lately
Girl I don’t think she knew me at all
Coz I never thought I'd have to say this
But I’m no liar, and I never hid
Anything, you should have seen it coming to this just now
I’m not singing for an ex though
I’m just singing cause it's over
The DJ Is Crying For Help
Everyone's laughin' at me
But not like they used to
The room's spinnin' all around me
But not like I'm used to

Hired, hired
Can I get hired?
I got no skills except gettin' high
I'm tryin', tryin'
I can start Friday
You've wasted your life but thanks for applying

Hey, now, hold up, we were fun as hell
I'm all grown up, but you couldn't tell
Now I don't know what to do with myself (Da da da da da da da)
You got older 'cause you good at life
I'm all seventeen at thirty-five
Now I don't know if there's anything else

The DJ is cryin' for help (Oh-oh-oh)
The DJ is cryin' for help (Oh-oh-oh)
Don't know what to do with myself
Hey now, hold up, we were fun as hell
I'm all grown up, but you couldn't tell
Now I don't know what to do with myself
The DJ is crying for help

Everyone's trippin' on pills
But now they're prescribed too
And everyone's stackin' their bills
But not 'cause they like to

Oh, hired, hired
Can I get hired?
Yeah, I ****ed up, but I did it my way
Tryin', tryin'
I could start Friday
Gettin' a life's a little like dyin'

Hey, now, hold up, we were fun as hell
I'm all grown up, but you couldn't tell
Now I don't know what to do with myself (Da da da da da da da)
You got older 'cause you're good at life
I'm all seventeen at thirty-five
Now I don't know if there's anything else

The DJ is cryin' for help (Drownin' me out)
The DJ is cryin' for help (Drownin' me out)
Don't know what to do with myself
Hey now, hold up, we were fun as hell
I'm all grown up, but you couldn't tell
Now I don't know what to do with myself
The DJ is cryin' for help
You got older 'cause you're good at life (Drownin' me out)
I'm all seventeen at thirty-five
Now I don't know if there's anything else
The DJ is crying for help

And now I'm all (I'm all) alone (Alone)
Waitin' for the beat to drop
Be kind to me, be kind and wait it out
And now I'm all (I'm all) alone (Alone)
Waitin' 'til the party starts
Be kind to me, be kind and wait it out

And now I'm all alone
Waitin' 'til the party starts

不过我感觉在我闲话里挂上歌词也没啥优势,不太能理解 Keven_He,SoyTony 和 APJifengc 给我投歌词的心态 .


看了 SDOI2019 移动金币 这个题,好像能推广到很多 Nim 游戏,还挺有意思的 .

以下所有除法默认向下取整 .

Bash 游戏

\(n\) 颗石子,Alice 和 Bob 轮流拿,每次拿 \(1\dots m\) 颗,不能拿者输 .

\(m\) 一定,计数所有先手必胜的局面 .

结论:\(n\bmod(m+1)\neq 0\) 先手必胜 .

然后就随便做了,时间复杂度 \(\Theta(1)\) .

Nim 游戏

\(k\) 堆石子 \(a_{1\dots k}\),Alice 和 Bob 轮流拿,每次任意选一堆拿任意颗,不能拿者输 .

石子总数 \(n\)\(k\) 一定,计数所有先手必胜的局面 .

结论:\(\displaystyle\bigoplus_{i=1}^ka_i\neq 0\) 先手必胜 .

首先所有局面的方案数就是插板法,于是单步容斥变为求先手必败方案数 .

于是有朴素 DP,令 \(dp_{i,j,k}\) 表示目前有 \(i\)\(j\) 颗石子,异或和为 \(k\) 的答案,时间复杂度 \(\Theta(nk^3)\) .

按位考虑,\(dp_{i,j}\) 表示前 \(i\) 位整完了,还有 \(j\) 个石子要放,转移大概就枚举 \(k\)\(2k\) 个位都加 \(2^i\) 个石子,这样异或和必然保持为 \(0\),时间复杂度 \(\Theta(nk\log n)\) .

然而这个状态到这里感觉也很难优化了,再换一个状态看一下:

\(dp_{b,i,j,w}\) 表示考虑到第 \(b\) 位,前 \(b-1\) 位异或和为 \(0\),正在考虑第 \(i\) 个石子的第 \(b\) 位,且异或和为 \(w\),目前共用 \(j\) 颗石子的方案数,这样也是 \(\Theta(nk\log n)\) .

实际上我们只关心 \(j=k\) 的情况,考虑 \(k\) 的某一位的来源,就是直接得到和前一位进位得到两种 .

从高到低考虑,令 \(dp_{b,i,s,w}\) 表示考虑到第 \(b\) 位,上 \(b-1\) 位异或和为 \(0\),正在考虑第 \(i\) 个石子的第 \(b\) 位,且异或和为 \(w\),欠下的进位和为 \(s\) 的方案数 .

好像没啥区别,但是可以发现,显然有 \(2^b\mid s\),且 \(\dfrac{s}{2^b}\le m+1\),否则肯定答案是 \(0\) .

于是第三维改成记 \(\dfrac s{2^b}\),这样就可以 \(\Theta(k^2\log n)\) 了 .

每堆地位相同,可以考虑从状态中去掉,令 \(dp_{b,s}\) 表示考虑到第 \(b\) 位,上 \(b-1\) 位异或和为 \(0\),欠下的进位和为 \(2^bs\) 的方案数,枚举第 \(b\) 位放多少位 \(1\) 即可转移,还是 \(\Theta(k^2\log k)\) 的,不过转移是卷积形式可以优化,就 \(\Theta(k\log k\log n)\) 了 .

如果从 \(\Theta(nk\log n)\) 背包卷积优化可以 \(O(n\log^2n)\) .

或者说首先按位考虑,假设到第 \(k\) 位了,那么当前位的 OGF 就是

\[F_k(z)=\sum_{2\mid i}\dbinom kiz^{i\cdot2^k} \]

直接全乘起来也可以得到 \(O(n\log^2n)\) .


还有一个方法看起来挺有意思的,来自 Ebola .

肯定还是先单步容斥,然后考虑如果 \(n\) 是奇数显然不可能异或和位 \(0\),后考虑 \(k\) 堆石子共 \(2n\) 个的方案数,记作 \(f_k(n)\) .

下记石子堆数为偶数的为「偶堆」,否则为「奇堆」,如果所有堆都是偶堆那么把所有堆的数量减半就得到一组 \(n\) 个石子的方案,于是可以建立起一般情况和仅包含偶堆情况的双射 .

于是考虑石子数量为 \(4n+2\)\(4n+4\) 的情况,首先说 \(4n+2\),令奇堆有 \(4i+2\) 个,则在每个奇堆中拿走一个石子,然后把所有堆的石子数减半,用双射关系即可得到:

\[f_k(2n+1)\sum_{i=0}^{\min\{n,k/4\}}\dbinom k{4i+2}f_k(n-i) \]

\(4n+4\) 的想法是基本一样的,最终可以得到

\[f_k(2n+2)=f_k(n+1)-\sum_{i=0}^{\min\{n,k/4\}}\dbinom k{4i+4}f_k(n-i) \]

于是就 \(\Theta(nk)\) 了 .

阶梯 Nim 游戏

\(k\) 堆石子 \(a_{1\dots k}\),Alice 和 Bob 轮流拿,每次任意选一堆拿任意颗扔到前一堆,不能拿者输 .

石子总数 \(n\)\(k\) 一定,计数所有先手必胜的局面 .

结论:先手必胜当且仅当奇数位石子数异或和非 \(0\) .

可以和 Nim 游戏一样做法,就 \(\Theta(k\log k\log n)\) 了 .

或者考虑直接归约过去,还是先单步容斥计数先手必败解,枚举偶数堆石子数插板即可得到必败解数目:

\[\sum_{i=1}^{n/2}\dbinom{n-2i+m-k-1}{m-k-1}\operatorname{Nim}(2i,k) \]

不过这么干好像就至少 \(\Theta(n\log n)\) 了,我没细想 .

不过 \(\Theta(\operatorname{poly}(m)\operatorname{polylog}(n))\) 肯定是不行了 .

Nim-k 游戏

\(k\) 堆石子 \(a_{1\dots k}\),Alice 和 Bob 轮流拿,每次任意选一堆拿 \(1\dots t\) 颗,不能拿者输 .

石子总数 \(n\)\(k\) 一定,计数所有先手必胜的局面 .

结论:先手必胜当且仅当存在某一二进制位满足 \(\{a\}\) 中所有二进制数对应位中 \(1\) 的个数之和不为 \(t+1\) 的倍数 .

然后仿 Nim 游戏就能 \(\Theta(ntk\log n)\) 了,类似做法大概也能 \(O(nt\log^2n)\) .

\(\Theta(tk\log k\log n)\) 感觉很有希望,不过我没太看懂那个进位的 DP 就不瞎胡了 .

Anti-Nim 游戏

\(k\) 堆石子 \(a_{1\dots k}\),Alice 和 Bob 轮流拿,每次任意选一堆拿任意颗,不能拿者赢 .

石子总数 \(n\)\(k\) 一定,计数所有先手必胜的局面 .

结论:直接看 SHOI2008 小约翰的游戏 吧 .

知道结论之后在 Nim 游戏上简单操作几下就完了 .

posted @ 2023-02-20 19:44  Jijidawang  阅读(72)  评论(5编辑  收藏  举报
😅​