mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-08 14:18:47 +00:00
1296. [SCOI2009]粉刷匠
https://hydro.ac/d/bzoj/record/6319d7a6533abd4b31874ab4
This commit is contained in:
parent
85613cc078
commit
eef109d013
64
BZOJ/1296/1296.cpp
Normal file
64
BZOJ/1296/1296.cpp
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using std::cin;
|
||||||
|
using std::cout;
|
||||||
|
const char endl = '\n';
|
||||||
|
|
||||||
|
const int N = 55;
|
||||||
|
|
||||||
|
int n, m, t, f[N][N][2], g[2505];
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::ios::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
|
||||||
|
cin >> n >> m >> t;
|
||||||
|
|
||||||
|
for (int i = 1; i <= n; i++) {
|
||||||
|
int last = 0;
|
||||||
|
std::string s;
|
||||||
|
std::vector<std::pair<int, int>> blocks;
|
||||||
|
|
||||||
|
cin >> s;
|
||||||
|
|
||||||
|
for (int j = 0; j < m; j++) {
|
||||||
|
if (s[j] != s[last]) {
|
||||||
|
blocks.emplace_back(last + 1, j);
|
||||||
|
last = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (last != m) {
|
||||||
|
blocks.emplace_back(last + 1, m);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 1; i <= blocks.size(); i++) {
|
||||||
|
const auto &block = blocks[i - 1];
|
||||||
|
|
||||||
|
for (int j = blocks.size(); j; j--) {
|
||||||
|
// 不染色时直接从前一格转移
|
||||||
|
f[i][j][0] = std::max(f[i - 1][j][0], f[i - 1][j][1]);
|
||||||
|
|
||||||
|
// 刷成和上个格子一样的颜色
|
||||||
|
f[i][j][1] = std::max(f[i - 1][j - 1][0], f[i - 1][j - 1][1]) + block.second - block.first + 1;
|
||||||
|
|
||||||
|
// 刷成和上上个格子一样的颜色
|
||||||
|
if (i >= 2) {
|
||||||
|
f[i][j][1] = std::max(f[i][j][1], f[i - 2][j][1] + block.second - block.first + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = t; j >= 0; j--) {
|
||||||
|
for (int k = 0; k <= std::min(j, static_cast<int>(blocks.size())); k++) {
|
||||||
|
g[j] = std::max(g[j], g[j - k] + std::max(f[blocks.size()][k][0], f[blocks.size()][k][1]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << g[t] << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
BIN
BZOJ/1296/data/1.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1296/data/1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1296/data/1.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1296/data/1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1296/data/10.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1296/data/10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1296/data/10.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1296/data/10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1296/data/2.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1296/data/2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1296/data/2.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1296/data/2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1296/data/3.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1296/data/3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1296/data/3.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1296/data/3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1296/data/4.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1296/data/4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1296/data/4.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1296/data/4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1296/data/5.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1296/data/5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1296/data/5.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1296/data/5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1296/data/6.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1296/data/6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1296/data/6.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1296/data/6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1296/data/7.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1296/data/7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1296/data/7.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1296/data/7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1296/data/8.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1296/data/8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1296/data/8.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1296/data/8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1296/data/9.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1296/data/9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1296/data/9.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1296/data/9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user