From b5f87613c92a1d2d9df0393707c182a916f471d2 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Thu, 4 Aug 2022 20:36:54 +0800 Subject: [PATCH] =?UTF-8?q?#2594.=20=E3=80=8CNOIP2010=E3=80=8D=E5=85=B3?= =?UTF-8?q?=E6=8A=BC=E7=BD=AA=E7=8A=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://loj.ac/s/1541617 --- LibreOJ/2594/2594.cpp | 75 ++++++++++++++++++++++++++++++++++ LibreOJ/2594/data/prison1.ans | 3 ++ LibreOJ/2594/data/prison1.in | 3 ++ LibreOJ/2594/data/prison10.ans | 3 ++ LibreOJ/2594/data/prison10.in | 3 ++ LibreOJ/2594/data/prison2.ans | 3 ++ LibreOJ/2594/data/prison2.in | 3 ++ LibreOJ/2594/data/prison3.ans | 3 ++ LibreOJ/2594/data/prison3.in | 3 ++ LibreOJ/2594/data/prison4.ans | 3 ++ LibreOJ/2594/data/prison4.in | 3 ++ LibreOJ/2594/data/prison5.ans | 3 ++ LibreOJ/2594/data/prison5.in | 3 ++ LibreOJ/2594/data/prison6.ans | 3 ++ LibreOJ/2594/data/prison6.in | 3 ++ LibreOJ/2594/data/prison7.ans | 3 ++ LibreOJ/2594/data/prison7.in | 3 ++ LibreOJ/2594/data/prison8.ans | 3 ++ LibreOJ/2594/data/prison8.in | 3 ++ LibreOJ/2594/data/prison9.ans | 3 ++ LibreOJ/2594/data/prison9.in | 3 ++ 21 files changed, 135 insertions(+) create mode 100644 LibreOJ/2594/2594.cpp create mode 100644 LibreOJ/2594/data/prison1.ans create mode 100644 LibreOJ/2594/data/prison1.in create mode 100644 LibreOJ/2594/data/prison10.ans create mode 100644 LibreOJ/2594/data/prison10.in create mode 100644 LibreOJ/2594/data/prison2.ans create mode 100644 LibreOJ/2594/data/prison2.in create mode 100644 LibreOJ/2594/data/prison3.ans create mode 100644 LibreOJ/2594/data/prison3.in create mode 100644 LibreOJ/2594/data/prison4.ans create mode 100644 LibreOJ/2594/data/prison4.in create mode 100644 LibreOJ/2594/data/prison5.ans create mode 100644 LibreOJ/2594/data/prison5.in create mode 100644 LibreOJ/2594/data/prison6.ans create mode 100644 LibreOJ/2594/data/prison6.in create mode 100644 LibreOJ/2594/data/prison7.ans create mode 100644 LibreOJ/2594/data/prison7.in create mode 100644 LibreOJ/2594/data/prison8.ans create mode 100644 LibreOJ/2594/data/prison8.in create mode 100644 LibreOJ/2594/data/prison9.ans create mode 100644 LibreOJ/2594/data/prison9.in diff --git a/LibreOJ/2594/2594.cpp b/LibreOJ/2594/2594.cpp new file mode 100644 index 00000000..6e57cbf9 --- /dev/null +++ b/LibreOJ/2594/2594.cpp @@ -0,0 +1,75 @@ +#include +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 20005; + +int n, m; +std::array color; +std::array>, N> g; + +bool dfs(int u, int color, int limit) { + ::color[u] = color; + + for (auto e : g[u]) { + int v = e.first, + w = e.second; + + if (w <= limit) continue; + if (::color[v]) { + if (::color[v] == color) return false; + } else if (!dfs(v, 3 - color, limit)) { + return false; + } + } + + return true; +} + +bool check(int limit) { + std::fill(color.begin(), color.end(), 0); + + for (int i = 1; i <= n; i++) { + if (!color[i]) { + if (!dfs(i, 1, limit)) return false; + } + } + + return true; +} + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> n >> m; + + for (int i = 1, u, v, w; i <= m; i++) { + cin >> u >> v >> w; + + g[u].emplace_back(v, w); + g[v].emplace_back(u, w); + } + + int l = 0, r = 1e9, ans = 0; + + while (l <= r) { + int mid = (l + r) >> 1; + + if (check(mid)) { + ans = mid; + r = mid - 1; + } else { + l = mid + 1; + } + } + + cout << ans << endl; + + return 0; +} diff --git a/LibreOJ/2594/data/prison1.ans b/LibreOJ/2594/data/prison1.ans new file mode 100644 index 00000000..804fcc90 --- /dev/null +++ b/LibreOJ/2594/data/prison1.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9a271f2a916b0b6ee6cecb2426f0b3206ef074578be55d9bc94f6f3fe3ab86aa +size 2 diff --git a/LibreOJ/2594/data/prison1.in b/LibreOJ/2594/data/prison1.in new file mode 100644 index 00000000..0e8faba0 --- /dev/null +++ b/LibreOJ/2594/data/prison1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b4360a4896fbd2f8c6641d62075b181a5df54a4fac7c739a6b7ff7d609453235 +size 14 diff --git a/LibreOJ/2594/data/prison10.ans b/LibreOJ/2594/data/prison10.ans new file mode 100644 index 00000000..d915cdd3 --- /dev/null +++ b/LibreOJ/2594/data/prison10.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b256953a3441ece9ea38748f321f46aca9997699b498ef24f43d0fae8c8306c3 +size 6 diff --git a/LibreOJ/2594/data/prison10.in b/LibreOJ/2594/data/prison10.in new file mode 100644 index 00000000..14e0ca3f --- /dev/null +++ b/LibreOJ/2594/data/prison10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:71369594a6ac740182f0afd1154134dff55430dbba0f1f4c48959a6b565e8d72 +size 1630814 diff --git a/LibreOJ/2594/data/prison2.ans b/LibreOJ/2594/data/prison2.ans new file mode 100644 index 00000000..2f4d73e9 --- /dev/null +++ b/LibreOJ/2594/data/prison2.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5233b8e366b04acdf6de5ac2f15bb5ca3f88693a10c35b564e0f4ee85f76a200 +size 6 diff --git a/LibreOJ/2594/data/prison2.in b/LibreOJ/2594/data/prison2.in new file mode 100644 index 00000000..317808ab --- /dev/null +++ b/LibreOJ/2594/data/prison2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a03eb0a56d28035db3c6aff4ecd1552914fd5c52ebccd8297f4e0a002c844517 +size 306 diff --git a/LibreOJ/2594/data/prison3.ans b/LibreOJ/2594/data/prison3.ans new file mode 100644 index 00000000..1faab98f --- /dev/null +++ b/LibreOJ/2594/data/prison3.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f788e6da08461109fa6b4f4771788ee6bd2e17d4554c583d5ba72614d4ae5bc6 +size 6 diff --git a/LibreOJ/2594/data/prison3.in b/LibreOJ/2594/data/prison3.in new file mode 100644 index 00000000..0e590abe --- /dev/null +++ b/LibreOJ/2594/data/prison3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0db7ad8f1d6036a60e84e5a2f6afc188c5f1420d6e526039975c6fdfa2928aef +size 632 diff --git a/LibreOJ/2594/data/prison4.ans b/LibreOJ/2594/data/prison4.ans new file mode 100644 index 00000000..3c00ec04 --- /dev/null +++ b/LibreOJ/2594/data/prison4.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9deba0c973f7997389b4e4bcd70f0ca31b7d2674ad34575dcd03c728b0fc5ea9 +size 6 diff --git a/LibreOJ/2594/data/prison4.in b/LibreOJ/2594/data/prison4.in new file mode 100644 index 00000000..0758437f --- /dev/null +++ b/LibreOJ/2594/data/prison4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:170994668d9cbfe0f33791585a3bb9304e9c879983555dbb8b43e89739d460c3 +size 34502 diff --git a/LibreOJ/2594/data/prison5.ans b/LibreOJ/2594/data/prison5.ans new file mode 100644 index 00000000..c728d61f --- /dev/null +++ b/LibreOJ/2594/data/prison5.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:afa500c35adfaa6f425193b6e131eb68c02a5937e385caf1985f38e6a452ddc0 +size 6 diff --git a/LibreOJ/2594/data/prison5.in b/LibreOJ/2594/data/prison5.in new file mode 100644 index 00000000..6408ff64 --- /dev/null +++ b/LibreOJ/2594/data/prison5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0be826b23da39b86b447789b23c79613743679c36c486cddc610ea004f1f5932 +size 13139 diff --git a/LibreOJ/2594/data/prison6.ans b/LibreOJ/2594/data/prison6.ans new file mode 100644 index 00000000..f9cee25e --- /dev/null +++ b/LibreOJ/2594/data/prison6.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:96dcec5d6d770e9477d3d39af3e89c421d246b6d0e448f969e9cb611a59824cc +size 6 diff --git a/LibreOJ/2594/data/prison6.in b/LibreOJ/2594/data/prison6.in new file mode 100644 index 00000000..2ffab688 --- /dev/null +++ b/LibreOJ/2594/data/prison6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:870582d4edf4b460389fe68510437bc6af650c412af882aef1316390d5eda5f1 +size 134325 diff --git a/LibreOJ/2594/data/prison7.ans b/LibreOJ/2594/data/prison7.ans new file mode 100644 index 00000000..546cc8c2 --- /dev/null +++ b/LibreOJ/2594/data/prison7.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b04073667b95e73f45745b6b1436f29f62c32993836a53e0de9e9c185cf9345a +size 6 diff --git a/LibreOJ/2594/data/prison7.in b/LibreOJ/2594/data/prison7.in new file mode 100644 index 00000000..34f5cef3 --- /dev/null +++ b/LibreOJ/2594/data/prison7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1d5185eb6b5e3084a8b8664c0e802773570c59c9fead50af8e34fa66c6ecbb27 +size 726176 diff --git a/LibreOJ/2594/data/prison8.ans b/LibreOJ/2594/data/prison8.ans new file mode 100644 index 00000000..ebe35e45 --- /dev/null +++ b/LibreOJ/2594/data/prison8.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:84792b6bee8f0f6c2fcc1ce5442bc50d19c3d0265f849d18e7486df760a7030b +size 6 diff --git a/LibreOJ/2594/data/prison8.in b/LibreOJ/2594/data/prison8.in new file mode 100644 index 00000000..76e76460 --- /dev/null +++ b/LibreOJ/2594/data/prison8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5e72b6a4454c9e43e401dd94e374d90e48df5ebca61c3fdd50edb907eb2361c5 +size 759195 diff --git a/LibreOJ/2594/data/prison9.ans b/LibreOJ/2594/data/prison9.ans new file mode 100644 index 00000000..4912515b --- /dev/null +++ b/LibreOJ/2594/data/prison9.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:323fa03774c4709732cb06e177aebc5e6d70e69d993e6bce6111ab72892926a0 +size 6 diff --git a/LibreOJ/2594/data/prison9.in b/LibreOJ/2594/data/prison9.in new file mode 100644 index 00000000..61bd4819 --- /dev/null +++ b/LibreOJ/2594/data/prison9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:19bbf50ebff646c70cf41cd0fac3edb6b7d7fc3f8d4bebcc5fd89296c8a9a148 +size 1538879