版本比较
题解:P16415 【MX-X28-T4】「FAOI-R12」落花雨
正文
增加 5 行删除 5 行
17 行未改动1819202122232425266 行未改动33343536373839404175 行未改动11711811912012112212312412512612712812913013117 行未改动for (int i = 1; i < (int)a.size(); i++) {vector<int> b(a.begin(), a.end());b[i - 1] = nor(a[i], a[i - 1]);b.erase(b.begin() + i);dfs(b);}}void _main() {6 行未改动cerr << ": ";for (int i : st) cerr << i << ' ';cerr << endl;}}```::::根据打表的结果,在 $n \ge 4$ 时所有串都能变成 $0$ 和 $1$,而无法变换的子串只有如下 $10$ 个:75 行未改动void _main() {cin >> n >> (s + 1);for (int x = 0; x < 16; x++) fill(f[x], f[x] + n + 1, 0);f[1][n] = 1; mint res = 0;for (int m = n; m >= 1; m--)for (int x = 0; x < 16; x++)for (int c : {0, 1}) {auto [m0, x0] = nxt(m, x, c);if (m0 == -1) continue;f[x0][m0] += f[x][m];if (m0 >= 4 || (x0 >> m0 & 1)) res += f[x][m];}cout << res << '\n';}```17 行未改动1819202122232425266 行未改动33343536373839404175 行未改动11711811912012112212312412512612712812913013117 行未改动for (int i = 1; i < (int)a.size(); i++) {vector<int> b(a.begin(), a.end());b[i - 1] = nor(a[i], a[i - 1]);b.erase(b.begin() + i);dfs(b);}}void _main() {6 行未改动cerr << ": ";for (int i : st) cerr << i << ' ';cerr << endl;}}```::::根据打表的结果,在 $n \ge 4$ 时所有串都能变成 $0$ 和 $1$,而无法变换的子串只有如下 $10$ 个:75 行未改动void _main() {cin >> n >> (s + 1);for (int x = 0; x < 16; x++) fill(f[x], f[x] + n + 1, 0);f[1][n] = 1; mint res = 0;for (int m = n; m >= 1; m--)for (int x = 0; x < 16; x++)for (int c : {0, 1}) {auto [m0, x0] = nxt(m, x, c);if (m0 == -1) continue;f[x0][m0] += f[x][m];if (m0 >= 4 || (x0 >> m0 & 1)) res += f[x][m];}cout << res << '\n';}```