From ef88d92c7b6b12d58597e346fe2b93cd618d46e1 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Thu, 4 Aug 2022 20:36:09 +0800 Subject: [PATCH] =?UTF-8?q?P1525=20[NOIP2010=20=E6=8F=90=E9=AB=98=E7=BB=84?= =?UTF-8?q?]=20=E5=85=B3=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://www.luogu.com.cn/record/82475050 --- Luogu/P1525/P1525.cpp | 75 +++++++++++++++++++++++++++++++++++ Luogu/P1525/data/P1525_1.in | 3 ++ Luogu/P1525/data/P1525_1.out | 3 ++ Luogu/P1525/data/P1525_10.in | 3 ++ Luogu/P1525/data/P1525_10.out | 3 ++ Luogu/P1525/data/P1525_2.in | 3 ++ Luogu/P1525/data/P1525_2.out | 3 ++ Luogu/P1525/data/P1525_3.in | 3 ++ Luogu/P1525/data/P1525_3.out | 3 ++ Luogu/P1525/data/P1525_4.in | 3 ++ Luogu/P1525/data/P1525_4.out | 3 ++ Luogu/P1525/data/P1525_5.in | 3 ++ Luogu/P1525/data/P1525_5.out | 3 ++ Luogu/P1525/data/P1525_6.in | 3 ++ Luogu/P1525/data/P1525_6.out | 3 ++ Luogu/P1525/data/P1525_7.in | 3 ++ Luogu/P1525/data/P1525_7.out | 3 ++ Luogu/P1525/data/P1525_8.in | 3 ++ Luogu/P1525/data/P1525_8.out | 3 ++ Luogu/P1525/data/P1525_9.in | 3 ++ Luogu/P1525/data/P1525_9.out | 3 ++ 21 files changed, 135 insertions(+) create mode 100644 Luogu/P1525/P1525.cpp create mode 100644 Luogu/P1525/data/P1525_1.in create mode 100644 Luogu/P1525/data/P1525_1.out create mode 100644 Luogu/P1525/data/P1525_10.in create mode 100644 Luogu/P1525/data/P1525_10.out create mode 100644 Luogu/P1525/data/P1525_2.in create mode 100644 Luogu/P1525/data/P1525_2.out create mode 100644 Luogu/P1525/data/P1525_3.in create mode 100644 Luogu/P1525/data/P1525_3.out create mode 100644 Luogu/P1525/data/P1525_4.in create mode 100644 Luogu/P1525/data/P1525_4.out create mode 100644 Luogu/P1525/data/P1525_5.in create mode 100644 Luogu/P1525/data/P1525_5.out create mode 100644 Luogu/P1525/data/P1525_6.in create mode 100644 Luogu/P1525/data/P1525_6.out create mode 100644 Luogu/P1525/data/P1525_7.in create mode 100644 Luogu/P1525/data/P1525_7.out create mode 100644 Luogu/P1525/data/P1525_8.in create mode 100644 Luogu/P1525/data/P1525_8.out create mode 100644 Luogu/P1525/data/P1525_9.in create mode 100644 Luogu/P1525/data/P1525_9.out diff --git a/Luogu/P1525/P1525.cpp b/Luogu/P1525/P1525.cpp new file mode 100644 index 00000000..6e57cbf9 --- /dev/null +++ b/Luogu/P1525/P1525.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/Luogu/P1525/data/P1525_1.in b/Luogu/P1525/data/P1525_1.in new file mode 100644 index 00000000..0e8faba0 --- /dev/null +++ b/Luogu/P1525/data/P1525_1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b4360a4896fbd2f8c6641d62075b181a5df54a4fac7c739a6b7ff7d609453235 +size 14 diff --git a/Luogu/P1525/data/P1525_1.out b/Luogu/P1525/data/P1525_1.out new file mode 100644 index 00000000..804fcc90 --- /dev/null +++ b/Luogu/P1525/data/P1525_1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9a271f2a916b0b6ee6cecb2426f0b3206ef074578be55d9bc94f6f3fe3ab86aa +size 2 diff --git a/Luogu/P1525/data/P1525_10.in b/Luogu/P1525/data/P1525_10.in new file mode 100644 index 00000000..14e0ca3f --- /dev/null +++ b/Luogu/P1525/data/P1525_10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:71369594a6ac740182f0afd1154134dff55430dbba0f1f4c48959a6b565e8d72 +size 1630814 diff --git a/Luogu/P1525/data/P1525_10.out b/Luogu/P1525/data/P1525_10.out new file mode 100644 index 00000000..d915cdd3 --- /dev/null +++ b/Luogu/P1525/data/P1525_10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b256953a3441ece9ea38748f321f46aca9997699b498ef24f43d0fae8c8306c3 +size 6 diff --git a/Luogu/P1525/data/P1525_2.in b/Luogu/P1525/data/P1525_2.in new file mode 100644 index 00000000..317808ab --- /dev/null +++ b/Luogu/P1525/data/P1525_2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a03eb0a56d28035db3c6aff4ecd1552914fd5c52ebccd8297f4e0a002c844517 +size 306 diff --git a/Luogu/P1525/data/P1525_2.out b/Luogu/P1525/data/P1525_2.out new file mode 100644 index 00000000..2f4d73e9 --- /dev/null +++ b/Luogu/P1525/data/P1525_2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5233b8e366b04acdf6de5ac2f15bb5ca3f88693a10c35b564e0f4ee85f76a200 +size 6 diff --git a/Luogu/P1525/data/P1525_3.in b/Luogu/P1525/data/P1525_3.in new file mode 100644 index 00000000..0e590abe --- /dev/null +++ b/Luogu/P1525/data/P1525_3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0db7ad8f1d6036a60e84e5a2f6afc188c5f1420d6e526039975c6fdfa2928aef +size 632 diff --git a/Luogu/P1525/data/P1525_3.out b/Luogu/P1525/data/P1525_3.out new file mode 100644 index 00000000..1faab98f --- /dev/null +++ b/Luogu/P1525/data/P1525_3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f788e6da08461109fa6b4f4771788ee6bd2e17d4554c583d5ba72614d4ae5bc6 +size 6 diff --git a/Luogu/P1525/data/P1525_4.in b/Luogu/P1525/data/P1525_4.in new file mode 100644 index 00000000..0758437f --- /dev/null +++ b/Luogu/P1525/data/P1525_4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:170994668d9cbfe0f33791585a3bb9304e9c879983555dbb8b43e89739d460c3 +size 34502 diff --git a/Luogu/P1525/data/P1525_4.out b/Luogu/P1525/data/P1525_4.out new file mode 100644 index 00000000..3c00ec04 --- /dev/null +++ b/Luogu/P1525/data/P1525_4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9deba0c973f7997389b4e4bcd70f0ca31b7d2674ad34575dcd03c728b0fc5ea9 +size 6 diff --git a/Luogu/P1525/data/P1525_5.in b/Luogu/P1525/data/P1525_5.in new file mode 100644 index 00000000..6408ff64 --- /dev/null +++ b/Luogu/P1525/data/P1525_5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0be826b23da39b86b447789b23c79613743679c36c486cddc610ea004f1f5932 +size 13139 diff --git a/Luogu/P1525/data/P1525_5.out b/Luogu/P1525/data/P1525_5.out new file mode 100644 index 00000000..c728d61f --- /dev/null +++ b/Luogu/P1525/data/P1525_5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:afa500c35adfaa6f425193b6e131eb68c02a5937e385caf1985f38e6a452ddc0 +size 6 diff --git a/Luogu/P1525/data/P1525_6.in b/Luogu/P1525/data/P1525_6.in new file mode 100644 index 00000000..2ffab688 --- /dev/null +++ b/Luogu/P1525/data/P1525_6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:870582d4edf4b460389fe68510437bc6af650c412af882aef1316390d5eda5f1 +size 134325 diff --git a/Luogu/P1525/data/P1525_6.out b/Luogu/P1525/data/P1525_6.out new file mode 100644 index 00000000..f9cee25e --- /dev/null +++ b/Luogu/P1525/data/P1525_6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:96dcec5d6d770e9477d3d39af3e89c421d246b6d0e448f969e9cb611a59824cc +size 6 diff --git a/Luogu/P1525/data/P1525_7.in b/Luogu/P1525/data/P1525_7.in new file mode 100644 index 00000000..34f5cef3 --- /dev/null +++ b/Luogu/P1525/data/P1525_7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1d5185eb6b5e3084a8b8664c0e802773570c59c9fead50af8e34fa66c6ecbb27 +size 726176 diff --git a/Luogu/P1525/data/P1525_7.out b/Luogu/P1525/data/P1525_7.out new file mode 100644 index 00000000..546cc8c2 --- /dev/null +++ b/Luogu/P1525/data/P1525_7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b04073667b95e73f45745b6b1436f29f62c32993836a53e0de9e9c185cf9345a +size 6 diff --git a/Luogu/P1525/data/P1525_8.in b/Luogu/P1525/data/P1525_8.in new file mode 100644 index 00000000..76e76460 --- /dev/null +++ b/Luogu/P1525/data/P1525_8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5e72b6a4454c9e43e401dd94e374d90e48df5ebca61c3fdd50edb907eb2361c5 +size 759195 diff --git a/Luogu/P1525/data/P1525_8.out b/Luogu/P1525/data/P1525_8.out new file mode 100644 index 00000000..ebe35e45 --- /dev/null +++ b/Luogu/P1525/data/P1525_8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:84792b6bee8f0f6c2fcc1ce5442bc50d19c3d0265f849d18e7486df760a7030b +size 6 diff --git a/Luogu/P1525/data/P1525_9.in b/Luogu/P1525/data/P1525_9.in new file mode 100644 index 00000000..61bd4819 --- /dev/null +++ b/Luogu/P1525/data/P1525_9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:19bbf50ebff646c70cf41cd0fac3edb6b7d7fc3f8d4bebcc5fd89296c8a9a148 +size 1538879 diff --git a/Luogu/P1525/data/P1525_9.out b/Luogu/P1525/data/P1525_9.out new file mode 100644 index 00000000..4912515b --- /dev/null +++ b/Luogu/P1525/data/P1525_9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:323fa03774c4709732cb06e177aebc5e6d70e69d993e6bce6111ab72892926a0 +size 6