版本比较
题解:P7098 [yLOI2020] 凉凉
正文
增加 4 行删除 4 行
8 行未改动910111213131415161749 行未改动6768697071727172737475767729 行未改动10710810911011211111211311411547 行未改动1631641651661678 行未改动此时答案为 $f_{n, 2^n - 1}$,这个显然。
还有就是,$f_{0, 0} = 0$,没有考虑的时候没有花费。
既然第 $dep$ 层的状态是 $s$,那么能给它转移的 $dep - 1$ 层的状态 肯定是它的子集。既然第 $dep$ 层的状态是 $s$,那么能给它转移的 $dep - 1$ 层的状态肯定是它的子集。
我们约定:
- $vis_{i, j}$ 表示 $i, j$ 两条地铁能否同高度;49 行未改动```
举个例子,当 $s = (101100)_2$ 时,我们会枚举到的 $t$ 有:$(101100)_2 \quad (101000)_2 \quad (100100)_2 \quad (100000)_2 \quad (001100)_2 \quad (001000)_2 \quad (000100)_2$。刚好是 $s$ 的非空子集们。空集也有转移,我们单独处理。
## Code
::::info[代码]```cpp//[yLOI2020] 凉凉#include <bits/stdc++.h>using std::cin;29 行未改动 return can[s] = true;}
void InitVis() { for(int i = 1; i <= n; ++i) for(int i = 1; i <= n; ++i) for(int j = i + 1; j <= n; ++j) { vis[i][j] = vis[j][i] = true; auto x = (pass[i] & pass[j]); if(x.any())47 行未改动 cout << f[n][(1 << n) - 1]; return 0;}```::::