diff --git a/BZOJ/1499/1499.cpp b/BZOJ/1499/1499.cpp new file mode 100644 index 00000000..a6dd4e9f --- /dev/null +++ b/BZOJ/1499/1499.cpp @@ -0,0 +1,112 @@ +#include +#include + +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> 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> 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> 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> 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; +} diff --git a/BZOJ/1499/data/1.in b/BZOJ/1499/data/1.in new file mode 100644 index 00000000..1701b2a6 --- /dev/null +++ b/BZOJ/1499/data/1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b2e148ec23526ff2ad045a2da2bae1a054b239c5ae2e6c7468a0e4444ffc6f7d +size 42793 diff --git a/BZOJ/1499/data/1.out b/BZOJ/1499/data/1.out new file mode 100644 index 00000000..5f81a224 --- /dev/null +++ b/BZOJ/1499/data/1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fc6c978e6d3372362bc5dfd72c188e1dae5c8dfce60ac930f7ae03ade5f86ba6 +size 5 diff --git a/BZOJ/1499/data/10.in b/BZOJ/1499/data/10.in new file mode 100644 index 00000000..03a4e8bc --- /dev/null +++ b/BZOJ/1499/data/10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:973f955ee82d6422cd4741f75cffb4c73f41574d74479495280aa275424316bd +size 42003 diff --git a/BZOJ/1499/data/10.out b/BZOJ/1499/data/10.out new file mode 100644 index 00000000..41f23e02 --- /dev/null +++ b/BZOJ/1499/data/10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:417742aec2ed2c52ee528213a2a58511e6bbb1c9b81acc2a72d4a8031daf1dec +size 4 diff --git a/BZOJ/1499/data/2.in b/BZOJ/1499/data/2.in new file mode 100644 index 00000000..1be68371 --- /dev/null +++ b/BZOJ/1499/data/2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:53152d06a9dee48f92261b66990d5766de1d39e5b7209a91bdda9fbf0082ff35 +size 618 diff --git a/BZOJ/1499/data/2.out b/BZOJ/1499/data/2.out new file mode 100644 index 00000000..65493889 --- /dev/null +++ b/BZOJ/1499/data/2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:084c799cd551dd1d8d5c5f9a5d593b2e931f5e36122ee5c793c1d08a19839cc0 +size 3 diff --git a/BZOJ/1499/data/3.in b/BZOJ/1499/data/3.in new file mode 100644 index 00000000..057eb0c9 --- /dev/null +++ b/BZOJ/1499/data/3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:623e65ed75fac045d697eccac66ec813637b5ebd2cb2b128a0b694185d0a8d8a +size 42583 diff --git a/BZOJ/1499/data/3.out b/BZOJ/1499/data/3.out new file mode 100644 index 00000000..5d1c4965 --- /dev/null +++ b/BZOJ/1499/data/3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0adb35c0a38741977ce8f12b16e9d8557ef2a6ab6f1fa12c9f9ed89a0753bf5c +size 5 diff --git a/BZOJ/1499/data/4.in b/BZOJ/1499/data/4.in new file mode 100644 index 00000000..12f46c4c --- /dev/null +++ b/BZOJ/1499/data/4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c7be30187a66d3be09e9fec3f81d78b20806967147640a70c57f65ad1918e631 +size 33366 diff --git a/BZOJ/1499/data/4.out b/BZOJ/1499/data/4.out new file mode 100644 index 00000000..b1e2939b --- /dev/null +++ b/BZOJ/1499/data/4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fe69f706ecd3014a757a39a5cbf8153871d634fc00c56fb9df119c1e3f7c2996 +size 5 diff --git a/BZOJ/1499/data/5.in b/BZOJ/1499/data/5.in new file mode 100644 index 00000000..8af99cbf --- /dev/null +++ b/BZOJ/1499/data/5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2f19d2ea85e0f57161f6dd30c540deca7d1819184c270237e13f19da60374a95 +size 10966 diff --git a/BZOJ/1499/data/5.out b/BZOJ/1499/data/5.out new file mode 100644 index 00000000..a67094e6 --- /dev/null +++ b/BZOJ/1499/data/5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:181210f8f9c779c26da1d9b2075bde0127302ee0e3fca38c9a83f5b1dd8e5d3b +size 4 diff --git a/BZOJ/1499/data/6.in b/BZOJ/1499/data/6.in new file mode 100644 index 00000000..b8b28546 --- /dev/null +++ b/BZOJ/1499/data/6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b6d7b318d18b1c1f0ead0546ca668cfad6fd31fee873d040491c65f502d69ada +size 404 diff --git a/BZOJ/1499/data/6.out b/BZOJ/1499/data/6.out new file mode 100644 index 00000000..1cd32466 --- /dev/null +++ b/BZOJ/1499/data/6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8e37bed9dff3949ffd23ae638260dff869f5cc26e551f2a9e5e289a8888949fa +size 3 diff --git a/BZOJ/1499/data/7.in b/BZOJ/1499/data/7.in new file mode 100644 index 00000000..0ee48f50 --- /dev/null +++ b/BZOJ/1499/data/7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f31f70a5f508ccf2e31a54a33a63f937b35fea3a7cf4f5004cef4a9a8ac2f8c1 +size 32429 diff --git a/BZOJ/1499/data/7.out b/BZOJ/1499/data/7.out new file mode 100644 index 00000000..d1e1c275 --- /dev/null +++ b/BZOJ/1499/data/7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ec0e96462fb897bf793288b87854ea7e0a875a8c0bdc19a4cfc7be16dffd8515 +size 5 diff --git a/BZOJ/1499/data/8.in b/BZOJ/1499/data/8.in new file mode 100644 index 00000000..bb894e0a --- /dev/null +++ b/BZOJ/1499/data/8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e0001f382b7016281b5bd761261d9d92d9f90c46658d25b9b143fdfef3f19e99 +size 42803 diff --git a/BZOJ/1499/data/8.out b/BZOJ/1499/data/8.out new file mode 100644 index 00000000..04f8b506 --- /dev/null +++ b/BZOJ/1499/data/8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:492e6c084ec0ed858740b587ca4acad2d419b8ca62479a2bb5a0afec5f353f9e +size 5 diff --git a/BZOJ/1499/data/9.in b/BZOJ/1499/data/9.in new file mode 100644 index 00000000..7ac0712c --- /dev/null +++ b/BZOJ/1499/data/9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a3ae8e496649fd380bf53568263e7c4571aa3247f7409e8431c2bcf994450eb0 +size 157 diff --git a/BZOJ/1499/data/9.out b/BZOJ/1499/data/9.out new file mode 100644 index 00000000..2ccf849a --- /dev/null +++ b/BZOJ/1499/data/9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:238903180cc104ec2c5d8b3f20c5bc61b389ec0a967df8cc208cdc7cd454174f +size 3