mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-08 15:18:46 +00:00
parent
2984c19860
commit
f91215fb07
86
Luogu/P2704/P2704.cpp
Normal file
86
Luogu/P2704/P2704.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
int n, m, cnt, s[105], f[105][105][105], ans;
|
||||
std::pair<int, int> r[105];
|
||||
|
||||
void dfs(int x, int sum, int len) {
|
||||
if (len >= m) {
|
||||
r[++cnt] = std::make_pair(x, sum);
|
||||
return;
|
||||
}
|
||||
|
||||
dfs(x, sum, len + 1);
|
||||
dfs(x + (1 << len), sum + 1, len + 3);
|
||||
}
|
||||
|
||||
bool check(int x, int y) {
|
||||
return !(s[x] & y);
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
|
||||
cin >> n >> m;
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = 1; j <= m; j++) {
|
||||
char c;
|
||||
cin >> c;
|
||||
|
||||
if (c == 'H') {
|
||||
s[i] |= 1 << m - j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dfs(0, 0, 0);
|
||||
|
||||
memset(f, 0xff, sizeof(f));
|
||||
f[0][0][0] = 0;
|
||||
for (int i = 1; i <= cnt; i++) {
|
||||
if (check(1, r[i].first)) {
|
||||
f[1][i][1] = r[i].second;
|
||||
|
||||
ans = std::max(ans, f[1][i][1]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 2; i <= n; i++) {
|
||||
for (int j = 1; j <= cnt; j++) {
|
||||
if (check(i, r[j].first)) {
|
||||
for (int k = 1; k <= cnt; k++) {
|
||||
if (check(i - 1, r[k].first) && !(r[j].first & r[k].first)) {
|
||||
int last = 0;
|
||||
|
||||
for (int l = 1; l <= cnt; l++) {
|
||||
if (~f[i - 1][k][l] && !(r[j].first & r[l].first) && check(i - 2, r[l].first)) {
|
||||
last = std::max(last, f[i - 1][k][l]);
|
||||
}
|
||||
}
|
||||
|
||||
f[i][j][k] = std::max(f[i][j][k], last + r[j].second);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i <= cnt; i++) {
|
||||
if (check(n, r[i].first)) {
|
||||
for (int j = 1; j <= cnt; j++) {
|
||||
if (check(n - 1, r[j].first) && !(r[i].first & r[j].first)) {
|
||||
ans = std::max(ans, f[n][i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cout << ans << endl;
|
||||
|
||||
return 0;
|
||||
}
|
BIN
Luogu/P2704/data/P2704_1.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2704/data/P2704_1.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2704/data/P2704_1.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2704/data/P2704_1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2704/data/P2704_10.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2704/data/P2704_10.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2704/data/P2704_10.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2704/data/P2704_10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2704/data/P2704_2.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2704/data/P2704_2.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2704/data/P2704_2.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2704/data/P2704_2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2704/data/P2704_3.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2704/data/P2704_3.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2704/data/P2704_3.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2704/data/P2704_3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2704/data/P2704_4.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2704/data/P2704_4.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2704/data/P2704_4.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2704/data/P2704_4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2704/data/P2704_5.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2704/data/P2704_5.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2704/data/P2704_5.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2704/data/P2704_5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2704/data/P2704_6.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2704/data/P2704_6.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2704/data/P2704_6.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2704/data/P2704_6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2704/data/P2704_7.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2704/data/P2704_7.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2704/data/P2704_7.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2704/data/P2704_7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2704/data/P2704_8.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2704/data/P2704_8.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2704/data/P2704_8.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2704/data/P2704_8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2704/data/P2704_9.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2704/data/P2704_9.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2704/data/P2704_9.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2704/data/P2704_9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2704/data/P2704_hack1.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2704/data/P2704_hack1.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2704/data/P2704_hack1.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2704/data/P2704_hack1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user