rt,代码:
#include <bits/stdc++.h>
#define int int64_t
const int maxn = 110;
const int maxm = (1 << 11);
int N, M;
char A;
int Farm[maxn];
int F[maxn][maxm][maxm];
std::vector<int> candidates;
auto popcount = [] (int x) {
auto lowbit = [] (int x) {return x & (-x); };
int cnt = 0;
while (x) {
x -= lowbit(x);
cnt += 1;
}
return cnt;
};
signed main() {
std::cin >> N >> M;
for (int i = 1; i <= N; i++)
for (int j = 1; j <= M; j++) {
std::cin >> A;
int a = (A == 'H');
Farm[i] |= (a << (j - 1));
}
for (int j = 0; j < (1 << M); j++)
if (!(j & (j << 1)) && !(j & (j >> 1)) && !(j & (j << 2)) && !(j & (j >> 2)))
candidates.push_back(j);
//for (int i = 1; i <= N; i++)
//std::cout << Farm[i] << " \n"[i == N];
for (int i = 1; i <= N; i++)
for (auto j : candidates)
if ((j & Farm[i]) == 0)
for (auto k : candidates)
for (auto p : candidates)
if (!(j & k) && !(j & p) && !(k & p))
F[i][j][k] = std::max(F[i - 1][k][p] + popcount(j), F[i][j][k]);
//for (int i = 1; i <= N; i++)
//for (int j = 0; j < (1 << M); j++)
//std::cout << F[i][j] << " \n"[j == (1 << M) - 1];
int res = 0;
for (auto j : candidates)
for (auto p : candidates)
res = (res + F[N][j][p]);
std::cout << res << std::endl;
return 0;
}
题目: P2704 [NOI2001] 炮兵阵地。
记录:https://www.luogu.com.cn/record/151204518
CE 信息:
No valid executable file was produced by the compiler
./ccBvvssq.o: in function `_GLOBAL__sub_I_src':
src:(.text.startup+0x2f7): relocation truncated to fit: R_X86_64_PC32 against `.bss'
src:(.text.startup+0x311): relocation truncated to fit: R_X86_64_PC32 against `.bss'
collect2: 错误:ld 返回 1