禁食后人(如果你100pts 但 hack 没过)

P2704 [NOI2001] 炮兵阵地

lyht @ 2024-08-18 21:05:05

可以加上: ```cpp n += 2, a[n - 1] = a[n] = s - 1; ``` 即在最下面加上两座“长城”,这样 $n$ 就大于等于 $3$ 了。 参考代码: ```cpp #include <bits/stdc++.h> using namespace std; const int N = (1 << 10) + 7; int n, m, s, ans, a[N], c[N], f[3][N][N]; char ch; main() { cin >> n >> m, s = (1 << m); for (int i = 1; i <= n; ++i) for (int j = 0; j < m; ++j) cin >> ch, a[i] |= (ch == 'H') << j; for (int i = 0; i < s; ++i) c[i] = __builtin_popcount(i); for (int i = 0; i < s; ++i) if (!(i & a[1] | i & (i << 1 | i << 2))) for (int j = 0; j < s; ++j) if (!(i & j | j & a[2] | j & (j << 1 | j << 2))) f[0][i][j] = c[i] + c[j]; n += 2, a[n - 1] = a[n] = s - 1; for (int i = 3; i <= n; ++i) for (int j = 0; j < s; ++j) if (!(j & a[i - 1] | j & (j << 1 | j << 2))) for (int k = 0; k < s; ++k) if (!(k & a[i] | k & (k << 1 | k << 2) | k & j)) for (int l = 0; l < s; ++l) if (!(l & a[i - 2] | l & (l << 1 | l << 2) | l & j | l & k)) f[i & 1][j][k] = max(f[i & 1][j][k], f[i - 1 & 1][l][j] + c[k]); for (int i = 0; i < s; ++i) for (int j = 0; j < s; ++j) ans = max(ans, f[n & 1][i][j]); return cout << ans, 0; }//f[i][j][k] = 前 i 行中,第 i 行状态为 j,第 i - 1 行状态为 k 的答案 ```

by wxzzzz @ 2024-08-18 21:10:56

发警示帖是虚伪的


by lyht @ 2024-08-19 17:17:06

@wxzzzz 为啥?


by wxzzzz @ 2024-08-19 17:18:20

@lyht 要是我实话告诉你我不就不虚伪了?


by lyht @ 2024-08-19 17:18:43

@wxzzzz 因为你是w虚z,还是你是w贺z?


by Manchester_Is_Blue @ 2024-08-21 18:30:43


by zhouxuanhong @ 2024-08-22 20:12:55

虽然我看不懂,但我大受震撼


by chu_yh @ 2024-09-07 17:25:04

那我对了hick,但其他都错呢


|