diff --git a/LibreOJ/3755/3755.cpp b/LibreOJ/3755/3755.cpp new file mode 100644 index 00000000..89469ff3 --- /dev/null +++ b/LibreOJ/3755/3755.cpp @@ -0,0 +1,68 @@ +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 1005; +const int INF = 0x3f3f3f3f; + +int c, n, f[N][1 << 8][20]; +std::pair a[N]; + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> c; + + while (c--) { + memset(f, 0x3f, sizeof(f)); + + cin >> n; + + for (int i = 1; i <= n; i++) { + cin >> a[i].first >> a[i].second; + } + + f[1][0][7] = 0; + for (int i = 1; i <= n; i++) { + for (int j = 0; j < 1 << 8; j++) { + for (int k = -8; k <= 7; k++) { + if (f[i][j][k + 8] != INF) { + if (j & 1) { // 当前同学吃了,无需考虑后方 + f[i + 1][j >> 1][k + 7] = std::min(f[i + 1][j >> 1][k + 7], f[i][j][k + 8]); + } else { + int t = INF; + + for (int l = 0; l <= 7; l++) { + if (j & 1 << l) continue; + if (i + l > t) break; + + if (i + l <= n) t = std::min(t, i + l + a[i + l].second); + else t = std::min(t, i + l); + + if (i + k) { + int x = i + k <= n ? a[i + k].first : 0, + y = i + l <= n ? a[i + l].first : 0; + f[i][j | 1 << l][l + 8] = std::min(f[i][j | 1 << l][l + 8], f[i][j][k + 8] + (x ^ y)); + } else { + f[i][j | 1 << l][l + 8] = std::min(f[i][j | 1 << l][l + 8], f[i][j][k + 8]); + } + } + } + } + } + } + } + + int ans = INF; + for (int i = 0; i <= 8; i++) { + ans = std::min(ans, f[n + 1][0][i]); + } + cout << ans << endl; + } + + return 0; +} diff --git a/LibreOJ/3755/data/1.in b/LibreOJ/3755/data/1.in new file mode 100644 index 00000000..c8a154bd --- /dev/null +++ b/LibreOJ/3755/data/1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:98ed6a75f9d6c6ac126748b40df4b579a754b62b558b4db04069b472a506fc47 +size 25812 diff --git a/LibreOJ/3755/data/1.out b/LibreOJ/3755/data/1.out new file mode 100644 index 00000000..a908038c --- /dev/null +++ b/LibreOJ/3755/data/1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:910dfbc60a68f6dbff62adc806969e394b6d0bed1e568e988976026cb9b7fb18 +size 30 diff --git a/LibreOJ/3755/data/10.in b/LibreOJ/3755/data/10.in new file mode 100644 index 00000000..d5aae230 --- /dev/null +++ b/LibreOJ/3755/data/10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dbc0b010526c732c9aea334f35b2da6b8fe6cd9f41d487cb7f74d002272f7d0d +size 9828 diff --git a/LibreOJ/3755/data/10.out b/LibreOJ/3755/data/10.out new file mode 100644 index 00000000..0a6fcaca --- /dev/null +++ b/LibreOJ/3755/data/10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7c3dce649408fd83f3e73e2a44d5a2200b0e8f1d80bc79426ccba237b3455c78 +size 18 diff --git a/LibreOJ/3755/data/11.in b/LibreOJ/3755/data/11.in new file mode 100644 index 00000000..047f9c4a --- /dev/null +++ b/LibreOJ/3755/data/11.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a487e65ae169323a14af31ce3f7f6d2ac6ddb5ff828000cf36f811c5cbdbcea1 +size 314 diff --git a/LibreOJ/3755/data/11.out b/LibreOJ/3755/data/11.out new file mode 100644 index 00000000..c2f483f7 --- /dev/null +++ b/LibreOJ/3755/data/11.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ecf43a24c66eaad663cc1e45c9cfd5dcb38b8f498b5556fb4591c4a9692279a4 +size 13 diff --git a/LibreOJ/3755/data/12.in b/LibreOJ/3755/data/12.in new file mode 100644 index 00000000..6aa24b0a --- /dev/null +++ b/LibreOJ/3755/data/12.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:92a9c2777c62c07ec48a76f7bfaffddf74cfcb80b9975adb69cc65c5f12d092b +size 152 diff --git a/LibreOJ/3755/data/12.out b/LibreOJ/3755/data/12.out new file mode 100644 index 00000000..b8d23c84 --- /dev/null +++ b/LibreOJ/3755/data/12.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8a4892a2faf038a0f4f1353eb45d084d37af7c9c32a1323b7398d5f63ba71a14 +size 20 diff --git a/LibreOJ/3755/data/13.in b/LibreOJ/3755/data/13.in new file mode 100644 index 00000000..eac673ff --- /dev/null +++ b/LibreOJ/3755/data/13.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5749a2ce60fbdb12f49977974e10bf7aed8886ddb30a5e27e030f98798fa6233 +size 14656 diff --git a/LibreOJ/3755/data/13.out b/LibreOJ/3755/data/13.out new file mode 100644 index 00000000..dbe2f264 --- /dev/null +++ b/LibreOJ/3755/data/13.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:177b42eadcf2bfa0fed6050398002a7e2e15c93024a4f8a06f752b5016835080 +size 35 diff --git a/LibreOJ/3755/data/14.in b/LibreOJ/3755/data/14.in new file mode 100644 index 00000000..10526d1a --- /dev/null +++ b/LibreOJ/3755/data/14.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:94fefc1ce268fdc24da72de323971e6634dc4e28e1dbedf4a42c53098f865feb +size 262 diff --git a/LibreOJ/3755/data/14.out b/LibreOJ/3755/data/14.out new file mode 100644 index 00000000..e32d633e --- /dev/null +++ b/LibreOJ/3755/data/14.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0f212d9e78b57fa0d083b25bbf6087480d68199c5b79a0e8e060a68b74686876 +size 16 diff --git a/LibreOJ/3755/data/15.in b/LibreOJ/3755/data/15.in new file mode 100644 index 00000000..f1902ea8 --- /dev/null +++ b/LibreOJ/3755/data/15.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d997745d1fa78a9aef03f30b7defa6ee2d99748207bc7037fca668898b962ee7 +size 247 diff --git a/LibreOJ/3755/data/15.out b/LibreOJ/3755/data/15.out new file mode 100644 index 00000000..333225d3 --- /dev/null +++ b/LibreOJ/3755/data/15.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ee7d3ec18ff808d70a10cdc7920b73c7ce0cee80e9ace75d0a2542c6afb51bf4 +size 20 diff --git a/LibreOJ/3755/data/16.in b/LibreOJ/3755/data/16.in new file mode 100644 index 00000000..42cabd20 --- /dev/null +++ b/LibreOJ/3755/data/16.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c2979a57b0ad4bb5ee599b5554c2e367035e79c34489200c98f0209bb7e3f2a9 +size 16528 diff --git a/LibreOJ/3755/data/16.out b/LibreOJ/3755/data/16.out new file mode 100644 index 00000000..77d0c08e --- /dev/null +++ b/LibreOJ/3755/data/16.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a9b8c1dc118421c6feb0d4999450ade868422d93d88912a001343dba0aad8ea3 +size 28 diff --git a/LibreOJ/3755/data/17.in b/LibreOJ/3755/data/17.in new file mode 100644 index 00000000..3a2bc255 --- /dev/null +++ b/LibreOJ/3755/data/17.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ea5aec2fc85c9e5e0be7783be78d9873b4ab140866bcea0757aafacb54d62fba +size 13583 diff --git a/LibreOJ/3755/data/17.out b/LibreOJ/3755/data/17.out new file mode 100644 index 00000000..db7ebd57 --- /dev/null +++ b/LibreOJ/3755/data/17.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8a3dbb79d4031185f16b71ce4113efd8c489903cac0cfd060794d894f20d7caf +size 24 diff --git a/LibreOJ/3755/data/18.in b/LibreOJ/3755/data/18.in new file mode 100644 index 00000000..7d223c95 --- /dev/null +++ b/LibreOJ/3755/data/18.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ef84842d4ff9112550470959911d0f893116fe6811d0ddf34236276cad1b2692 +size 10621 diff --git a/LibreOJ/3755/data/18.out b/LibreOJ/3755/data/18.out new file mode 100644 index 00000000..62b4b1b5 --- /dev/null +++ b/LibreOJ/3755/data/18.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:715f56f8512e5823f6e2ef33193f7ceba5552199448f7eff8856c367f5ea84a4 +size 20 diff --git a/LibreOJ/3755/data/19.in b/LibreOJ/3755/data/19.in new file mode 100644 index 00000000..1360e91c --- /dev/null +++ b/LibreOJ/3755/data/19.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a6e2609a5a3847710dbf9167687fc2ad960144b9348dbbc97b9a5bf8c4dd61b2 +size 20871 diff --git a/LibreOJ/3755/data/19.out b/LibreOJ/3755/data/19.out new file mode 100644 index 00000000..66da4704 --- /dev/null +++ b/LibreOJ/3755/data/19.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:626f316d0f0462704fe082910521b8b74580ca2f41db5b36b8f875ddb07aa287 +size 28 diff --git a/LibreOJ/3755/data/2.in b/LibreOJ/3755/data/2.in new file mode 100644 index 00000000..562b7982 --- /dev/null +++ b/LibreOJ/3755/data/2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7137a3bafc91dbb0877a952c17e2ab698b0630f4cb73b8ceb9d38dc364b300ee +size 23598 diff --git a/LibreOJ/3755/data/2.out b/LibreOJ/3755/data/2.out new file mode 100644 index 00000000..f12c5026 --- /dev/null +++ b/LibreOJ/3755/data/2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ef91c054b7143da65a632ccd2c51eb202318c83dbc83d0a21a0bac737b361ba3 +size 28 diff --git a/LibreOJ/3755/data/20.in b/LibreOJ/3755/data/20.in new file mode 100644 index 00000000..9c179c8a --- /dev/null +++ b/LibreOJ/3755/data/20.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f354620c89e9e2b6d062aebc0ad3e077f6f2482af5da4c8712cbb8d4479a904d +size 483 diff --git a/LibreOJ/3755/data/20.out b/LibreOJ/3755/data/20.out new file mode 100644 index 00000000..e9c5ae97 --- /dev/null +++ b/LibreOJ/3755/data/20.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:971ee1162a7d2f9c49f999d2c9f4f0cb022b90e6afdeff97aa2cedca0d759f9d +size 20 diff --git a/LibreOJ/3755/data/21.in b/LibreOJ/3755/data/21.in new file mode 100644 index 00000000..490c50c0 --- /dev/null +++ b/LibreOJ/3755/data/21.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:889d6f7d70daba1e17275d29dbb366f5e78844e302626f4b69b4ac607aba7ebe +size 17435 diff --git a/LibreOJ/3755/data/21.out b/LibreOJ/3755/data/21.out new file mode 100644 index 00000000..d14be9b8 --- /dev/null +++ b/LibreOJ/3755/data/21.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dd15b6340b229ab3a142e62504aa4ca1942a7b668f50845d7cc5a26a79cb9b2f +size 21 diff --git a/LibreOJ/3755/data/22.in b/LibreOJ/3755/data/22.in new file mode 100644 index 00000000..c4de2067 --- /dev/null +++ b/LibreOJ/3755/data/22.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0019eb3741f91af4c8898df17257de0052b54539318f0a5309fc4c7e0d74449c +size 20621 diff --git a/LibreOJ/3755/data/22.out b/LibreOJ/3755/data/22.out new file mode 100644 index 00000000..7a6a9661 --- /dev/null +++ b/LibreOJ/3755/data/22.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aadcddaec39d92dcddb3a97e221c8d2c0743afba5ffdb285be5e4dde92ade467 +size 30 diff --git a/LibreOJ/3755/data/23.in b/LibreOJ/3755/data/23.in new file mode 100644 index 00000000..2191f9c5 --- /dev/null +++ b/LibreOJ/3755/data/23.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f9772828bc3b01c93422a0d3db9b72e9ba8954b9c099b72fe2ba699a9ae3957e +size 112 diff --git a/LibreOJ/3755/data/23.out b/LibreOJ/3755/data/23.out new file mode 100644 index 00000000..d586ca2e --- /dev/null +++ b/LibreOJ/3755/data/23.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:02ad244ae58ca933c7db0a1cb9b417d1d44a6a1aadfa8e1bb991fdf86cd2bbf1 +size 9 diff --git a/LibreOJ/3755/data/24.in b/LibreOJ/3755/data/24.in new file mode 100644 index 00000000..89e4ac79 --- /dev/null +++ b/LibreOJ/3755/data/24.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:576b97e08a174628a7a5d574326304c46eeacaa83fa97a95377662c4fd2145f6 +size 17656 diff --git a/LibreOJ/3755/data/24.out b/LibreOJ/3755/data/24.out new file mode 100644 index 00000000..3e206e95 --- /dev/null +++ b/LibreOJ/3755/data/24.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1640ee8546caabe4d6eae8d208ac302a877303579212b4fb5801775af54680af +size 21 diff --git a/LibreOJ/3755/data/25.in b/LibreOJ/3755/data/25.in new file mode 100644 index 00000000..767f5af8 --- /dev/null +++ b/LibreOJ/3755/data/25.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:48e3861a07902456a9f226862b078ca5d2243abe59347501977c56b384401fc5 +size 18827 diff --git a/LibreOJ/3755/data/25.out b/LibreOJ/3755/data/25.out new file mode 100644 index 00000000..4cd172ca --- /dev/null +++ b/LibreOJ/3755/data/25.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:885d19f717c075bc63b932ed882e6910c5fd18faaeab3e0a9926b419528a9684 +size 29 diff --git a/LibreOJ/3755/data/3.in b/LibreOJ/3755/data/3.in new file mode 100644 index 00000000..f0190559 --- /dev/null +++ b/LibreOJ/3755/data/3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4b11e026e84945ee9ee6a992303ff854634533f30677bdde5c950580932b19ef +size 19628 diff --git a/LibreOJ/3755/data/3.out b/LibreOJ/3755/data/3.out new file mode 100644 index 00000000..1dcc1181 --- /dev/null +++ b/LibreOJ/3755/data/3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:42880adf762e7400a72fbe9eb306083f5030d36ce8f0e579f3cbe6b05a3425f3 +size 24 diff --git a/LibreOJ/3755/data/4.in b/LibreOJ/3755/data/4.in new file mode 100644 index 00000000..f7940254 --- /dev/null +++ b/LibreOJ/3755/data/4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:795caffc34e917de500814fd8c49e239eb9f4b251d8c6607659d90f058e8861a +size 10312 diff --git a/LibreOJ/3755/data/4.out b/LibreOJ/3755/data/4.out new file mode 100644 index 00000000..0be3a930 --- /dev/null +++ b/LibreOJ/3755/data/4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:532a9356cbf519583043a4dfac2ce335cb827c21be226cb1d46938500d9b795b +size 30 diff --git a/LibreOJ/3755/data/5.in b/LibreOJ/3755/data/5.in new file mode 100644 index 00000000..8fa580b5 --- /dev/null +++ b/LibreOJ/3755/data/5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e6b4877603ce6faaa6e2e45a685e29354d61962141c12d0f970321298d9ba0a3 +size 295 diff --git a/LibreOJ/3755/data/5.out b/LibreOJ/3755/data/5.out new file mode 100644 index 00000000..6fabb8f6 --- /dev/null +++ b/LibreOJ/3755/data/5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:adfc8b4feca3a6dcfa546a27ce4fee11ee1f403b49456c6076ed6e6507dc61da +size 15 diff --git a/LibreOJ/3755/data/6.in b/LibreOJ/3755/data/6.in new file mode 100644 index 00000000..b86056f4 --- /dev/null +++ b/LibreOJ/3755/data/6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f865f159cdcd5e002dc2522a774a0c6febc73a899cdab37e3b47b7a5dacc0063 +size 11801 diff --git a/LibreOJ/3755/data/6.out b/LibreOJ/3755/data/6.out new file mode 100644 index 00000000..6e68a0bc --- /dev/null +++ b/LibreOJ/3755/data/6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c49a413259cc66d9168b841422cc37b7d4b5c2dee6fada87d221750123ff22c2 +size 28 diff --git a/LibreOJ/3755/data/7.in b/LibreOJ/3755/data/7.in new file mode 100644 index 00000000..8ac148ca --- /dev/null +++ b/LibreOJ/3755/data/7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f1c8a2233bbadb510fe288b57454b7fe717bec3fc325da2a0b88e1d5d083dbc6 +size 549 diff --git a/LibreOJ/3755/data/7.out b/LibreOJ/3755/data/7.out new file mode 100644 index 00000000..87d1916b --- /dev/null +++ b/LibreOJ/3755/data/7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b6e3f8f82359d2e9504d2bac3e892a11b4a46a85d88f3856946673b4e7f1db7f +size 25 diff --git a/LibreOJ/3755/data/8.in b/LibreOJ/3755/data/8.in new file mode 100644 index 00000000..deb41ab2 --- /dev/null +++ b/LibreOJ/3755/data/8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a56104ab490b93698246ace295b19bd185992619716c0141235f992d83433f49 +size 16226 diff --git a/LibreOJ/3755/data/8.out b/LibreOJ/3755/data/8.out new file mode 100644 index 00000000..f910f8b0 --- /dev/null +++ b/LibreOJ/3755/data/8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6249de8061e121967f6e7504108e0b0f12707ed21768ae3af3b7898efb59cb90 +size 28 diff --git a/LibreOJ/3755/data/9.in b/LibreOJ/3755/data/9.in new file mode 100644 index 00000000..3558953e --- /dev/null +++ b/LibreOJ/3755/data/9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7f92b2303656d536dcdeb3a244d50964a8b649dda6bf75c322276b55e2ecd56a +size 14125 diff --git a/LibreOJ/3755/data/9.out b/LibreOJ/3755/data/9.out new file mode 100644 index 00000000..bad88e8d --- /dev/null +++ b/LibreOJ/3755/data/9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2f9bd6327afdb5b81c647ce89874725935630c6f92f571d1ff491d7e0929c367 +size 18