mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-27 13:56:26 +00:00
1499. [NOI2005] 瑰丽华尔兹
https://hydro.ac/d/bzoj/record/6322ec32bdf9bc31d160a063
This commit is contained in:
parent
244f91eef3
commit
e10acb110f
112
BZOJ/1499/1499.cpp
Normal file
112
BZOJ/1499/1499.cpp
Normal file
@ -0,0 +1,112 @@
|
||||
#include <iostream>
|
||||
#include <deque>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 205;
|
||||
|
||||
int n, m, x, y, k, s, t, d, f[N][N], ans;
|
||||
bool g[N][N];
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> n >> m >> x >> y >> k;
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = 1; j <= m; j++) {
|
||||
char c;
|
||||
cin >> c;
|
||||
g[i][j] = c == 'x';
|
||||
f[i][j] = -0x3f3f3f3f;
|
||||
}
|
||||
}
|
||||
|
||||
f[x][y] = 0;
|
||||
for (int i = 1; i <= k; i++) {
|
||||
cin >> s >> t >> d;
|
||||
|
||||
int len = t - s + 1;
|
||||
switch (d) {
|
||||
case 1: { // 上
|
||||
for (int y = 1; y <= m; y++) {
|
||||
std::deque<std::pair<int, int>> q;
|
||||
for (int j = 1, x = n; x; j++, x--) {
|
||||
if (g[x][y]) {
|
||||
q.clear();
|
||||
} else {
|
||||
while (!q.empty() && q.back().second < f[x][y] - j) q.pop_back();
|
||||
q.push_back(std::make_pair(j, f[x][y] - j));
|
||||
while (!q.empty() && j - q.front().first > len) q.pop_front();
|
||||
f[x][y] = q.front().second + j;
|
||||
ans = std::max(ans, f[x][y]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: { // 下
|
||||
for (int y = 1; y <= m; y++) {
|
||||
std::deque<std::pair<int, int>> q;
|
||||
for (int j = 1, x = 1; x <= n; j++, x++) {
|
||||
if (g[x][y]) {
|
||||
q.clear();
|
||||
} else {
|
||||
while (!q.empty() && q.back().second < f[x][y] - j) q.pop_back();
|
||||
q.push_back(std::make_pair(j, f[x][y] - j));
|
||||
while (!q.empty() && j - q.front().first > len) q.pop_front();
|
||||
f[x][y] = q.front().second + j;
|
||||
ans = std::max(ans, f[x][y]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: { // 左
|
||||
for (int x = 1; x <= n; x++) {
|
||||
std::deque<std::pair<int, int>> q;
|
||||
for (int j = 1, y = m; y; j++, y--) {
|
||||
if (g[x][y]) {
|
||||
q.clear();
|
||||
} else {
|
||||
while (!q.empty() && q.back().second < f[x][y] - j) q.pop_back();
|
||||
q.push_back(std::make_pair(j, f[x][y] - j));
|
||||
while (!q.empty() && j - q.front().first > len) q.pop_front();
|
||||
f[x][y] = q.front().second + j;
|
||||
ans = std::max(ans, f[x][y]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 4: { // 右
|
||||
for (int x = 1; x <= n; x++) {
|
||||
std::deque<std::pair<int, int>> q;
|
||||
for (int j = 1, y = 1; y <= m; j++, y++) {
|
||||
if (g[x][y]) {
|
||||
q.clear();
|
||||
} else {
|
||||
while (!q.empty() && q.back().second < f[x][y] - j) q.pop_back();
|
||||
q.push_back(std::make_pair(j, f[x][y] - j));
|
||||
while (!q.empty() && j - q.front().first > len) q.pop_front();
|
||||
f[x][y] = q.front().second + j;
|
||||
ans = std::max(ans, f[x][y]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cout << ans << endl;
|
||||
|
||||
return 0;
|
||||
}
|
BIN
BZOJ/1499/data/1.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/1.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/10.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/10.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/2.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/2.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/3.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/3.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/4.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/4.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/5.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/5.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/6.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/6.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/7.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/7.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/8.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/8.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/9.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/9.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user