From 9a5892035df67536206a7d2994623156c6d4bea8 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Tue, 14 Feb 2023 16:29:05 +0800 Subject: [PATCH] #1847. [COCI2017-2018#7] Go https://sjzezoj.com/submission/69942 --- S2OJ/1847/1847.cpp | 84 +++++++++++++++++++++++++++++++++++++ S2OJ/1847/data/ex_go1.in | 3 ++ S2OJ/1847/data/ex_go1.out | 3 ++ S2OJ/1847/data/ex_go2.in | 3 ++ S2OJ/1847/data/ex_go2.out | 3 ++ S2OJ/1847/data/go1.in | 3 ++ S2OJ/1847/data/go1.out | 3 ++ S2OJ/1847/data/go10.in | 3 ++ S2OJ/1847/data/go10.out | 3 ++ S2OJ/1847/data/go2.in | 3 ++ S2OJ/1847/data/go2.out | 3 ++ S2OJ/1847/data/go3.in | 3 ++ S2OJ/1847/data/go3.out | 3 ++ S2OJ/1847/data/go4.in | 3 ++ S2OJ/1847/data/go4.out | 3 ++ S2OJ/1847/data/go5.in | 3 ++ S2OJ/1847/data/go5.out | 3 ++ S2OJ/1847/data/go6.in | 3 ++ S2OJ/1847/data/go6.out | 3 ++ S2OJ/1847/data/go7.in | 3 ++ S2OJ/1847/data/go7.out | 3 ++ S2OJ/1847/data/go8.in | 3 ++ S2OJ/1847/data/go8.out | 3 ++ S2OJ/1847/data/go9.in | 3 ++ S2OJ/1847/data/go9.out | 3 ++ S2OJ/1847/data/problem.conf | 3 ++ 26 files changed, 159 insertions(+) create mode 100644 S2OJ/1847/1847.cpp create mode 100644 S2OJ/1847/data/ex_go1.in create mode 100644 S2OJ/1847/data/ex_go1.out create mode 100644 S2OJ/1847/data/ex_go2.in create mode 100644 S2OJ/1847/data/ex_go2.out create mode 100644 S2OJ/1847/data/go1.in create mode 100644 S2OJ/1847/data/go1.out create mode 100644 S2OJ/1847/data/go10.in create mode 100644 S2OJ/1847/data/go10.out create mode 100644 S2OJ/1847/data/go2.in create mode 100644 S2OJ/1847/data/go2.out create mode 100644 S2OJ/1847/data/go3.in create mode 100644 S2OJ/1847/data/go3.out create mode 100644 S2OJ/1847/data/go4.in create mode 100644 S2OJ/1847/data/go4.out create mode 100644 S2OJ/1847/data/go5.in create mode 100644 S2OJ/1847/data/go5.out create mode 100644 S2OJ/1847/data/go6.in create mode 100644 S2OJ/1847/data/go6.out create mode 100644 S2OJ/1847/data/go7.in create mode 100644 S2OJ/1847/data/go7.out create mode 100644 S2OJ/1847/data/go8.in create mode 100644 S2OJ/1847/data/go8.out create mode 100644 S2OJ/1847/data/go9.in create mode 100644 S2OJ/1847/data/go9.out create mode 100644 S2OJ/1847/data/problem.conf diff --git a/S2OJ/1847/1847.cpp b/S2OJ/1847/1847.cpp new file mode 100644 index 00000000..b9a03689 --- /dev/null +++ b/S2OJ/1847/1847.cpp @@ -0,0 +1,84 @@ +#include +#include +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 2005, + M = 105; + +int n, k, m, a[M], b[M], t[M], max, ans; +// 访问过最左端的房子为 l +// 最右端的房子为 r +// 时间已经过了 k 秒 +// 目前正在 左(0) / 右(1) 端 +int f[M][M][N][2]; + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + memset(f, 0xc0, sizeof(f)); + + cin >> n >> k >> m; + + for (int i = 1; i <= m; i++) { + cin >> a[i] >> b[i] >> t[i]; + + max = std::max(max, t[i]); + } + + int x = std::distance(a, std::lower_bound(a + 1, a + 1 + m, k)), + y = std::distance(a, std::upper_bound(a + 1, a + 1 + m, k)) - 1; + + if (a[x] == k) { + f[x][x][0][0] + = f[x][x][0][1] + = (std::abs(a[x] - k) < t[x]) * b[x]; + } else { // 起始点没有宝可梦 + f[x][x][std::abs(a[x] - k)][0] + = f[x][x][std::abs(a[x] - k)][1] + = (std::abs(a[x] - k) < t[x]) * b[x]; + f[y][y][std::abs(a[y] - k)][0] + = f[y][y][std::abs(a[y] - k)][1] + = (std::abs(a[y] - k) < t[y]) * b[y]; + } + + for (int len = 2; len <= m; len++) { + for (int l = 1, r = l + len - 1; r <= m; l++, r++) { + for (int k = a[r] - a[l]; k <= max; k++) { + f[l][r][k][0] = std::max({ + f[l][r][k][0], + f[l + 1][r][k - (a[l + 1] - a[l])][0] + (k < t[l]) * b[l], + f[l + 1][r][k - (a[r] - a[l])][1] + (k < t[l]) * b[l], + }); + + f[l][r][k][1] = std::max({ + f[l][r][k][1], + f[l][r - 1][k - (a[r] - a[r - 1])][1] + (k < t[r]) * b[r], + f[l][r - 1][k - (a[r] - a[l])][0] + (k < t[r]) * b[r], + }); + } + } + } + + for (int l = 1; l <= m; l++) { + for (int r = l; r <= m; r++) { + for (int k = 0; k <= max; k++) { + ans = std::max({ + ans, + f[l][r][k][0], + f[l][r][k][1], + }); + } + } + } + + cout << ans << endl; + + return 0; +} diff --git a/S2OJ/1847/data/ex_go1.in b/S2OJ/1847/data/ex_go1.in new file mode 100644 index 00000000..f6cd1b7c --- /dev/null +++ b/S2OJ/1847/data/ex_go1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:40cdd23359b100cb11d5e4918dec7d4d4114e1a39edc0e77cddcea70ae5e9575 +size 37 diff --git a/S2OJ/1847/data/ex_go1.out b/S2OJ/1847/data/ex_go1.out new file mode 100644 index 00000000..93f810ce --- /dev/null +++ b/S2OJ/1847/data/ex_go1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e623772cc677b6536e0545bc9870ad53a37b5cf0187fcc9851641b52344c7ee8 +size 4 diff --git a/S2OJ/1847/data/ex_go2.in b/S2OJ/1847/data/ex_go2.in new file mode 100644 index 00000000..67a3e99c --- /dev/null +++ b/S2OJ/1847/data/ex_go2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e90c84471034ced4738fb83b9a2b37583f68c3c3ec905dad94f0440e14377a5b +size 60 diff --git a/S2OJ/1847/data/ex_go2.out b/S2OJ/1847/data/ex_go2.out new file mode 100644 index 00000000..0b5bd735 --- /dev/null +++ b/S2OJ/1847/data/ex_go2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cc1bdefa1677283e90c64275f66ccd52fe41900b9c53763e2e1058dc971c01b6 +size 4 diff --git a/S2OJ/1847/data/go1.in b/S2OJ/1847/data/go1.in new file mode 100644 index 00000000..1a73eb34 --- /dev/null +++ b/S2OJ/1847/data/go1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:252e6aa86841c51fd05154bd25470b14a553c08457ddac3ab8aced0e5cb29397 +size 51 diff --git a/S2OJ/1847/data/go1.out b/S2OJ/1847/data/go1.out new file mode 100644 index 00000000..a67094e6 --- /dev/null +++ b/S2OJ/1847/data/go1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:181210f8f9c779c26da1d9b2075bde0127302ee0e3fca38c9a83f5b1dd8e5d3b +size 4 diff --git a/S2OJ/1847/data/go10.in b/S2OJ/1847/data/go10.in new file mode 100644 index 00000000..955761c5 --- /dev/null +++ b/S2OJ/1847/data/go10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4cbe41f898a1f7b7ed280a3d9d378078302f50bd5163946faa5f21228f49627f +size 1059 diff --git a/S2OJ/1847/data/go10.out b/S2OJ/1847/data/go10.out new file mode 100644 index 00000000..0d863317 --- /dev/null +++ b/S2OJ/1847/data/go10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d2b7478dc8a208b35e7f3e2d2501edf4417ababf5991e0096260055652c960de +size 5 diff --git a/S2OJ/1847/data/go2.in b/S2OJ/1847/data/go2.in new file mode 100644 index 00000000..699b5b36 --- /dev/null +++ b/S2OJ/1847/data/go2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9c51f343d1d9c849c84d339cac36dee06bc0d455e9170df8ec0566e0c9069515 +size 114 diff --git a/S2OJ/1847/data/go2.out b/S2OJ/1847/data/go2.out new file mode 100644 index 00000000..933257fb --- /dev/null +++ b/S2OJ/1847/data/go2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cd1f7fa2be52425b90bfd563bfe5df873000a900f0c7bdbe1095ff28fee19e6c +size 4 diff --git a/S2OJ/1847/data/go3.in b/S2OJ/1847/data/go3.in new file mode 100644 index 00000000..c9040762 --- /dev/null +++ b/S2OJ/1847/data/go3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:750290ef9844440692c2a8b6f529a9e68b5f5df5f53b975dc698779b5f2d764f +size 129 diff --git a/S2OJ/1847/data/go3.out b/S2OJ/1847/data/go3.out new file mode 100644 index 00000000..79d7f298 --- /dev/null +++ b/S2OJ/1847/data/go3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:387071454b158127fea5cc3f04d95bed131c730d8a10587194dbb320635083a8 +size 4 diff --git a/S2OJ/1847/data/go4.in b/S2OJ/1847/data/go4.in new file mode 100644 index 00000000..8131bd78 --- /dev/null +++ b/S2OJ/1847/data/go4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1849517d151942666b01afe0619c5fd6f40955cf4b9088b3bcd917f5cad5da10 +size 217 diff --git a/S2OJ/1847/data/go4.out b/S2OJ/1847/data/go4.out new file mode 100644 index 00000000..3d4c80aa --- /dev/null +++ b/S2OJ/1847/data/go4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f8de392b88cbc0c25ad7724620c3cbc750be7032e2f6c0938eb175dbada2640d +size 4 diff --git a/S2OJ/1847/data/go5.in b/S2OJ/1847/data/go5.in new file mode 100644 index 00000000..3b14e27f --- /dev/null +++ b/S2OJ/1847/data/go5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:97e597ec385b11a0f71be3e4e476ce00a03f4b8d1a10b4b0d2db65e112b16c95 +size 518 diff --git a/S2OJ/1847/data/go5.out b/S2OJ/1847/data/go5.out new file mode 100644 index 00000000..36ca39c4 --- /dev/null +++ b/S2OJ/1847/data/go5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2b52988e6a5f86d72ecf8b59fa8ed58a174663d54001db9db8190f9692fb1489 +size 4 diff --git a/S2OJ/1847/data/go6.in b/S2OJ/1847/data/go6.in new file mode 100644 index 00000000..ee217fd3 --- /dev/null +++ b/S2OJ/1847/data/go6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c73d06abd38b9fed18505e7070576a26e39b440d8cd2566cfb3056a8f0979ddc +size 563 diff --git a/S2OJ/1847/data/go6.out b/S2OJ/1847/data/go6.out new file mode 100644 index 00000000..3b973a5c --- /dev/null +++ b/S2OJ/1847/data/go6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:235581d056dd1693dc024d34609a415c987a1d85ec24db61b443b66c9b8b72ca +size 5 diff --git a/S2OJ/1847/data/go7.in b/S2OJ/1847/data/go7.in new file mode 100644 index 00000000..61df64ec --- /dev/null +++ b/S2OJ/1847/data/go7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:83bf4217dcdb81840a0c9640f9218143280bfe40ed2a71f280cc9331df186f71 +size 749 diff --git a/S2OJ/1847/data/go7.out b/S2OJ/1847/data/go7.out new file mode 100644 index 00000000..5fbf0466 --- /dev/null +++ b/S2OJ/1847/data/go7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7b630f5f160efb69c5d6a27aa24158f62550209b0ad62d4e70622eb5f0de0fbe +size 5 diff --git a/S2OJ/1847/data/go8.in b/S2OJ/1847/data/go8.in new file mode 100644 index 00000000..881b097e --- /dev/null +++ b/S2OJ/1847/data/go8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4281d7d15f1069c42ed93d658d8b97516323f7816669d0293ca368d800ca12bd +size 853 diff --git a/S2OJ/1847/data/go8.out b/S2OJ/1847/data/go8.out new file mode 100644 index 00000000..7195899a --- /dev/null +++ b/S2OJ/1847/data/go8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6ab4cca2e549669b8ed1304e0512977f811a8b948edc0cef7253c220ecbfc4ca +size 5 diff --git a/S2OJ/1847/data/go9.in b/S2OJ/1847/data/go9.in new file mode 100644 index 00000000..05f4c07f --- /dev/null +++ b/S2OJ/1847/data/go9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9af5f506c28dda0f9d384a59e47b05ee691c333db7e4753bfd20ac16273bf25b +size 916 diff --git a/S2OJ/1847/data/go9.out b/S2OJ/1847/data/go9.out new file mode 100644 index 00000000..e022c3a7 --- /dev/null +++ b/S2OJ/1847/data/go9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5b2e2407a8958d736d1f53d10b501046d6401f31c4e7939076d5d02676d91b8b +size 5 diff --git a/S2OJ/1847/data/problem.conf b/S2OJ/1847/data/problem.conf new file mode 100644 index 00000000..66a70a70 --- /dev/null +++ b/S2OJ/1847/data/problem.conf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:135d3fb06cda98a20fd226706a3364f88972e8ef25c2352b80732d2d60ac5cab +size 175