From 5ef368076287db785860f9c84bb480d896840813 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Thu, 15 Sep 2022 17:19:46 +0800 Subject: [PATCH] 2794. [POI2012] Cloakroom https://hydro.ac/d/bzoj/record/6322ee0c32ae6c3198cc9eee --- BZOJ/2794/2794.cpp | 64 +++++++++++++++++++++++++++++++++++++++++++ BZOJ/2794/data/1.in | 3 ++ BZOJ/2794/data/1.out | 3 ++ BZOJ/2794/data/10.in | 3 ++ BZOJ/2794/data/10.out | 3 ++ BZOJ/2794/data/11.in | 3 ++ BZOJ/2794/data/11.out | 3 ++ BZOJ/2794/data/12.in | 3 ++ BZOJ/2794/data/12.out | 3 ++ BZOJ/2794/data/13.in | 3 ++ BZOJ/2794/data/13.out | 3 ++ BZOJ/2794/data/14.in | 3 ++ BZOJ/2794/data/14.out | 3 ++ BZOJ/2794/data/15.in | 3 ++ BZOJ/2794/data/15.out | 3 ++ BZOJ/2794/data/16.in | 3 ++ BZOJ/2794/data/16.out | 3 ++ BZOJ/2794/data/17.in | 3 ++ BZOJ/2794/data/17.out | 3 ++ BZOJ/2794/data/2.in | 3 ++ BZOJ/2794/data/2.out | 3 ++ BZOJ/2794/data/3.in | 3 ++ BZOJ/2794/data/3.out | 3 ++ BZOJ/2794/data/4.in | 3 ++ BZOJ/2794/data/4.out | 3 ++ BZOJ/2794/data/5.in | 3 ++ BZOJ/2794/data/5.out | 3 ++ BZOJ/2794/data/6.in | 3 ++ BZOJ/2794/data/6.out | 3 ++ BZOJ/2794/data/7.in | 3 ++ BZOJ/2794/data/7.out | 3 ++ BZOJ/2794/data/8.in | 3 ++ BZOJ/2794/data/8.out | 3 ++ BZOJ/2794/data/9.in | 3 ++ BZOJ/2794/data/9.out | 3 ++ 35 files changed, 166 insertions(+) create mode 100644 BZOJ/2794/2794.cpp create mode 100644 BZOJ/2794/data/1.in create mode 100644 BZOJ/2794/data/1.out create mode 100644 BZOJ/2794/data/10.in create mode 100644 BZOJ/2794/data/10.out create mode 100644 BZOJ/2794/data/11.in create mode 100644 BZOJ/2794/data/11.out create mode 100644 BZOJ/2794/data/12.in create mode 100644 BZOJ/2794/data/12.out create mode 100644 BZOJ/2794/data/13.in create mode 100644 BZOJ/2794/data/13.out create mode 100644 BZOJ/2794/data/14.in create mode 100644 BZOJ/2794/data/14.out create mode 100644 BZOJ/2794/data/15.in create mode 100644 BZOJ/2794/data/15.out create mode 100644 BZOJ/2794/data/16.in create mode 100644 BZOJ/2794/data/16.out create mode 100644 BZOJ/2794/data/17.in create mode 100644 BZOJ/2794/data/17.out create mode 100644 BZOJ/2794/data/2.in create mode 100644 BZOJ/2794/data/2.out create mode 100644 BZOJ/2794/data/3.in create mode 100644 BZOJ/2794/data/3.out create mode 100644 BZOJ/2794/data/4.in create mode 100644 BZOJ/2794/data/4.out create mode 100644 BZOJ/2794/data/5.in create mode 100644 BZOJ/2794/data/5.out create mode 100644 BZOJ/2794/data/6.in create mode 100644 BZOJ/2794/data/6.out create mode 100644 BZOJ/2794/data/7.in create mode 100644 BZOJ/2794/data/7.out create mode 100644 BZOJ/2794/data/8.in create mode 100644 BZOJ/2794/data/8.out create mode 100644 BZOJ/2794/data/9.in create mode 100644 BZOJ/2794/data/9.out diff --git a/BZOJ/2794/2794.cpp b/BZOJ/2794/2794.cpp new file mode 100644 index 00000000..5c84ffd8 --- /dev/null +++ b/BZOJ/2794/2794.cpp @@ -0,0 +1,64 @@ +#include +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 1005, + P = 1e6 + 5; + +int n, p, f[P]; +bool ans[P]; +std::tuple a[N]; +std::tuple b[P]; + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> n; + + for (int i = 1; i <= n; i++) { + cin >> std::get<2>(a[i]) >> std::get<0>(a[i]) >> std::get<1>(a[i]); + } + + std::sort(a + 1, a + 1 + n, [&](auto a, auto b) { + return std::get<0>(a) < std::get<0>(b); + }); + + cin >> p; + + for (int i = 1; i <= p; i++) { + cin >> std::get<1>(b[i]) >> std::get<2>(b[i]) >> std::get<3>(b[i]); + std::get<0>(b[i]) = i; + } + + std::sort(b + 1, b + 1 + p, [&](auto a, auto b) { + return std::get<1>(a) < std::get<1>(b); + }); + + f[0] = std::numeric_limits::max(); + for (int i = 1, j = 1; i <= p; i++) { + while (std::get<0>(a[j]) <= std::get<1>(b[i]) && j <= n) { + for (int k = 100000; k >= std::get<2>(a[j]); k--) { + f[k] = std::max(f[k], + std::min(f[k - std::get<2>(a[j])], + std::get<1>(a[j]))); + } + j++; + } + + if (f[std::get<2>(b[i])] > std::get<1>(b[i]) + std::get<3>(b[i])) { + ans[std::get<0>(b[i])] = true; + } + } + + for (int i = 1; i <= p; i++) { + cout << (ans[i] ? "TAK" : "NIE") << endl; + } + + return 0; +} diff --git a/BZOJ/2794/data/1.in b/BZOJ/2794/data/1.in new file mode 100644 index 00000000..566460f5 --- /dev/null +++ b/BZOJ/2794/data/1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:28a08997327093a92998040aa425d5faba4d17c8d2ac90b9cce23af61924c283 +size 64 diff --git a/BZOJ/2794/data/1.out b/BZOJ/2794/data/1.out new file mode 100644 index 00000000..ad97c56f --- /dev/null +++ b/BZOJ/2794/data/1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5daf5ed7ef0e5e409a5d9ec3ac85f4b40effa369ae9f57f7f6c8f7b615e4b388 +size 20 diff --git a/BZOJ/2794/data/10.in b/BZOJ/2794/data/10.in new file mode 100644 index 00000000..f3fcb391 --- /dev/null +++ b/BZOJ/2794/data/10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9dfc6755f4d32fbda9fcf74eddbb244ec4312b0c9bc56242396329772bff7bdf +size 14223184 diff --git a/BZOJ/2794/data/10.out b/BZOJ/2794/data/10.out new file mode 100644 index 00000000..7a7bc4ce --- /dev/null +++ b/BZOJ/2794/data/10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8a81b824e371ae7769a265c6092904442fa5203ddedad52188ac128d276c996a +size 2848272 diff --git a/BZOJ/2794/data/11.in b/BZOJ/2794/data/11.in new file mode 100644 index 00000000..43e5f68d --- /dev/null +++ b/BZOJ/2794/data/11.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:634b33b2be2c38e35c9ec87b5c930aea7578e26bbc9e4e9d95777e257ad0f919 +size 4556 diff --git a/BZOJ/2794/data/11.out b/BZOJ/2794/data/11.out new file mode 100644 index 00000000..1654ce19 --- /dev/null +++ b/BZOJ/2794/data/11.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:649e2b57872fff4b151083d1bf61b0f3fd4bc740716034137ac4e5dd8e783944 +size 40 diff --git a/BZOJ/2794/data/12.in b/BZOJ/2794/data/12.in new file mode 100644 index 00000000..c952b9f2 --- /dev/null +++ b/BZOJ/2794/data/12.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6a0e5e229998d0f691765e97cffc4f7b040d01107619046bb0a47decce4685ed +size 1099134 diff --git a/BZOJ/2794/data/12.out b/BZOJ/2794/data/12.out new file mode 100644 index 00000000..b45b8fff --- /dev/null +++ b/BZOJ/2794/data/12.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c4f0c178666074e81c071df19324026e2a0796943ccea568ffa57912570dd0da +size 217344 diff --git a/BZOJ/2794/data/13.in b/BZOJ/2794/data/13.in new file mode 100644 index 00000000..2024a4ab --- /dev/null +++ b/BZOJ/2794/data/13.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:674736569ad592b31c4eb42dc4c241babe0bb84f3ccd6c4390770622993d3d81 +size 3676259 diff --git a/BZOJ/2794/data/13.out b/BZOJ/2794/data/13.out new file mode 100644 index 00000000..142dba43 --- /dev/null +++ b/BZOJ/2794/data/13.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9e5ff5a645b6fcb60b9c1d1f82c7c60d9575c52cd89bb0ab70d80bc07517dfe7 +size 914432 diff --git a/BZOJ/2794/data/14.in b/BZOJ/2794/data/14.in new file mode 100644 index 00000000..0938fd64 --- /dev/null +++ b/BZOJ/2794/data/14.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:76a7226577698e2737ae4db29923f1b206738fd273256423fb557f452886b46c +size 10173974 diff --git a/BZOJ/2794/data/14.out b/BZOJ/2794/data/14.out new file mode 100644 index 00000000..1756b005 --- /dev/null +++ b/BZOJ/2794/data/14.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:81dbd5085cdc5086d2d89e6bf1c2e8592367fad879ef781590f9cd53eec0ad08 +size 1998800 diff --git a/BZOJ/2794/data/15.in b/BZOJ/2794/data/15.in new file mode 100644 index 00000000..5f8622f0 --- /dev/null +++ b/BZOJ/2794/data/15.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ffefffa95412c770b6555ab16df4b64909edfe849b378403475d4aaad1ee32ea +size 1983070 diff --git a/BZOJ/2794/data/15.out b/BZOJ/2794/data/15.out new file mode 100644 index 00000000..5210dfce --- /dev/null +++ b/BZOJ/2794/data/15.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d8ea6b209734dad322b7fc2a4ac1945b0b538fd203d789a36a85d5e6f457fb67 +size 492800 diff --git a/BZOJ/2794/data/16.in b/BZOJ/2794/data/16.in new file mode 100644 index 00000000..71b4215a --- /dev/null +++ b/BZOJ/2794/data/16.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:484ad4e26966549986912d1c2d2495cb2305dda24be5e5353e7334390609174e +size 16779595 diff --git a/BZOJ/2794/data/16.out b/BZOJ/2794/data/16.out new file mode 100644 index 00000000..6503087f --- /dev/null +++ b/BZOJ/2794/data/16.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0eb35b3d6b886c8c98a6508654e977453e13a1362158d0fb4d721c4e889c1f5b +size 4000000 diff --git a/BZOJ/2794/data/17.in b/BZOJ/2794/data/17.in new file mode 100644 index 00000000..af258283 --- /dev/null +++ b/BZOJ/2794/data/17.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7d9a378bb2895ee18edcac218da52b5f50f8fdd62e3c521865e347b1f35270bc +size 6080825 diff --git a/BZOJ/2794/data/17.out b/BZOJ/2794/data/17.out new file mode 100644 index 00000000..ea9f6ba2 --- /dev/null +++ b/BZOJ/2794/data/17.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5b4eb319e5e7838afd7462c73d84675f8057f9336e4535f8f4c28737dd641648 +size 1201248 diff --git a/BZOJ/2794/data/2.in b/BZOJ/2794/data/2.in new file mode 100644 index 00000000..d477a57a --- /dev/null +++ b/BZOJ/2794/data/2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:320c286e34feeaced0c9de3555a038523dab596b6c6761e5c491353f528be975 +size 20409898 diff --git a/BZOJ/2794/data/2.out b/BZOJ/2794/data/2.out new file mode 100644 index 00000000..1b14495b --- /dev/null +++ b/BZOJ/2794/data/2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ccbbea1a08faf0578a79382214b9901209780476ae1fad98a31c902d9d1eaa73 +size 4000000 diff --git a/BZOJ/2794/data/3.in b/BZOJ/2794/data/3.in new file mode 100644 index 00000000..c2e4ddc6 --- /dev/null +++ b/BZOJ/2794/data/3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9133aec030b5bd463f267c10142706426dc88d5e72b5894376cbea86ac8bd0d9 +size 252451 diff --git a/BZOJ/2794/data/3.out b/BZOJ/2794/data/3.out new file mode 100644 index 00000000..8350a1c6 --- /dev/null +++ b/BZOJ/2794/data/3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:322d67fbd8553df999abc6a16e43394e6fc1bda8ad86a72fbb30f30f0376863a +size 49488 diff --git a/BZOJ/2794/data/4.in b/BZOJ/2794/data/4.in new file mode 100644 index 00000000..6dcc503e --- /dev/null +++ b/BZOJ/2794/data/4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e6722563bf12fdb0ccdb7813ea8fca75fe3e18397b26cd927d786bddad90d155 +size 157 diff --git a/BZOJ/2794/data/4.out b/BZOJ/2794/data/4.out new file mode 100644 index 00000000..b511d5fb --- /dev/null +++ b/BZOJ/2794/data/4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7f71b0a42155fa82fa005122a5578668293fa63fbca3030ff85b8e3e38a152bd +size 48 diff --git a/BZOJ/2794/data/5.in b/BZOJ/2794/data/5.in new file mode 100644 index 00000000..61e19fcd --- /dev/null +++ b/BZOJ/2794/data/5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aa082d3da03626802ad8887d7088476b89128d0b25dec9f6995563185e93b1b1 +size 118 diff --git a/BZOJ/2794/data/5.out b/BZOJ/2794/data/5.out new file mode 100644 index 00000000..f56a681a --- /dev/null +++ b/BZOJ/2794/data/5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ca32dbf9ab08fa0a768e6aff7269e17186ceb0606d60ddf20186a0abadde1f71 +size 40 diff --git a/BZOJ/2794/data/6.in b/BZOJ/2794/data/6.in new file mode 100644 index 00000000..1613d70b --- /dev/null +++ b/BZOJ/2794/data/6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8a3a9b9c998840a2130a9f963646b326f447e9b8130e004ece328d8b83a3123f +size 398 diff --git a/BZOJ/2794/data/6.out b/BZOJ/2794/data/6.out new file mode 100644 index 00000000..37a821b4 --- /dev/null +++ b/BZOJ/2794/data/6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9317ea17aa55f83a6278c1a1fdca751d0f8e910a0458781d835687b9729ca3ce +size 40 diff --git a/BZOJ/2794/data/7.in b/BZOJ/2794/data/7.in new file mode 100644 index 00000000..b76f8bcd --- /dev/null +++ b/BZOJ/2794/data/7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9e6abc4b15f7c1040d02c6418fcdeb036bf6a3d6a0b0b23252adb607cfbbf0c4 +size 2483367 diff --git a/BZOJ/2794/data/7.out b/BZOJ/2794/data/7.out new file mode 100644 index 00000000..cc267b80 --- /dev/null +++ b/BZOJ/2794/data/7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:67c770ca650ee668cbf5f36bcdd6c7920c732b8acc0e9612d4bbd65c0a1e189c +size 494016 diff --git a/BZOJ/2794/data/8.in b/BZOJ/2794/data/8.in new file mode 100644 index 00000000..750a6676 --- /dev/null +++ b/BZOJ/2794/data/8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ccb43b5088492906cf7fcfe7539f6e5e75aa62a37bda28cbe4c944680ea69f42 +size 5699210 diff --git a/BZOJ/2794/data/8.out b/BZOJ/2794/data/8.out new file mode 100644 index 00000000..eff0f773 --- /dev/null +++ b/BZOJ/2794/data/8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5dcc56bfac9ea5bf295d890862529dc6c7d29d764f6c5da1c24c43a0cbe6998c +size 1417680 diff --git a/BZOJ/2794/data/9.in b/BZOJ/2794/data/9.in new file mode 100644 index 00000000..dca87ca6 --- /dev/null +++ b/BZOJ/2794/data/9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:feb19044a986cb43c8fae24d97d6ac4a040be520c947a77099fb8ffa3bfb936a +size 131 diff --git a/BZOJ/2794/data/9.out b/BZOJ/2794/data/9.out new file mode 100644 index 00000000..a3a28522 --- /dev/null +++ b/BZOJ/2794/data/9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b441430a3ec82865fda343a1034ee0a46f1f14eb75c85022319a7853ea46e975 +size 40