From f62e720b8e6dc882934f86b95a23a6ea765aceef Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Wed, 4 Jan 2023 19:29:54 +0800 Subject: [PATCH] =?UTF-8?q?1059.=20[ZJOI2007]=E7=9F=A9=E9=98=B5=E6=B8=B8?= =?UTF-8?q?=E6=88=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://hydro.ac/d/bzoj/record/63b5630e291ec3514f4c4113 --- BZOJ/1059/1059.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++ BZOJ/1059/data/1.in | 3 +++ BZOJ/1059/data/1.out | 3 +++ BZOJ/1059/data/10.in | 3 +++ BZOJ/1059/data/10.out | 3 +++ BZOJ/1059/data/2.in | 3 +++ BZOJ/1059/data/2.out | 3 +++ BZOJ/1059/data/3.in | 3 +++ BZOJ/1059/data/3.out | 3 +++ BZOJ/1059/data/4.in | 3 +++ BZOJ/1059/data/4.out | 3 +++ BZOJ/1059/data/5.in | 3 +++ BZOJ/1059/data/5.out | 3 +++ BZOJ/1059/data/6.in | 3 +++ BZOJ/1059/data/6.out | 3 +++ BZOJ/1059/data/7.in | 3 +++ BZOJ/1059/data/7.out | 3 +++ BZOJ/1059/data/8.in | 3 +++ BZOJ/1059/data/8.out | 3 +++ BZOJ/1059/data/9.in | 3 +++ BZOJ/1059/data/9.out | 3 +++ 21 files changed, 118 insertions(+) create mode 100644 BZOJ/1059/1059.cpp create mode 100644 BZOJ/1059/data/1.in create mode 100644 BZOJ/1059/data/1.out create mode 100644 BZOJ/1059/data/10.in create mode 100644 BZOJ/1059/data/10.out create mode 100644 BZOJ/1059/data/2.in create mode 100644 BZOJ/1059/data/2.out create mode 100644 BZOJ/1059/data/3.in create mode 100644 BZOJ/1059/data/3.out create mode 100644 BZOJ/1059/data/4.in create mode 100644 BZOJ/1059/data/4.out create mode 100644 BZOJ/1059/data/5.in create mode 100644 BZOJ/1059/data/5.out create mode 100644 BZOJ/1059/data/6.in create mode 100644 BZOJ/1059/data/6.out create mode 100644 BZOJ/1059/data/7.in create mode 100644 BZOJ/1059/data/7.out create mode 100644 BZOJ/1059/data/8.in create mode 100644 BZOJ/1059/data/8.out create mode 100644 BZOJ/1059/data/9.in create mode 100644 BZOJ/1059/data/9.out diff --git a/BZOJ/1059/1059.cpp b/BZOJ/1059/1059.cpp new file mode 100644 index 00000000..8be6f7d8 --- /dev/null +++ b/BZOJ/1059/1059.cpp @@ -0,0 +1,58 @@ +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + int t; + + cin >> t; + + while (t--) { + int n; + + cin >> n; + + int ans = 0; + std::vector tag(n, -1), match(n, -1); + std::vector> g(n); + + for (int i = 0; i < n; i++) { + for (int j = 0, x; j < n; j++) { + cin >> x; + + if (x) g[i].emplace_back(j); + } + } + + std::function dfs = [&](int u, int t) { + if (tag[u] == t) return false; + + tag[u] = t; + + for (int v : g[u]) { + if (match[v] == -1 || dfs(match[v], t)) { + match[v] = u; + + return true; + } + } + + return false; + }; + + for (int i = 0; i < n; i++) { + if (dfs(i, i)) ans++; + } + + cout << (ans == n ? "Yes" : "No") << endl; + } + + return 0; +} diff --git a/BZOJ/1059/data/1.in b/BZOJ/1059/data/1.in new file mode 100644 index 00000000..2eafd8de --- /dev/null +++ b/BZOJ/1059/data/1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:50b4c3817b19369d09cd95b7706d9c63a32bdad85121b587c08746c8a929a7f7 +size 4302 diff --git a/BZOJ/1059/data/1.out b/BZOJ/1059/data/1.out new file mode 100644 index 00000000..88536675 --- /dev/null +++ b/BZOJ/1059/data/1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:02f9618864ea78a6aac04c3f8ece4f9fed09647c4d2cad0082f46c9fcec97de8 +size 42 diff --git a/BZOJ/1059/data/10.in b/BZOJ/1059/data/10.in new file mode 100644 index 00000000..c421a3d4 --- /dev/null +++ b/BZOJ/1059/data/10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:790043eb51385d9c065056e92fb23ea9a95d0983cd1da2ef6034b833f249519b +size 484 diff --git a/BZOJ/1059/data/10.out b/BZOJ/1059/data/10.out new file mode 100644 index 00000000..09d83601 --- /dev/null +++ b/BZOJ/1059/data/10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cbb339695df166f005950dbd57a4901ad340f6be56a7412311956174d2ba7eb0 +size 23 diff --git a/BZOJ/1059/data/2.in b/BZOJ/1059/data/2.in new file mode 100644 index 00000000..24044053 --- /dev/null +++ b/BZOJ/1059/data/2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a23cb9c9531493e5211b9cd422c980aa696b99cd2fc69fcff5763ec0896062be +size 158 diff --git a/BZOJ/1059/data/2.out b/BZOJ/1059/data/2.out new file mode 100644 index 00000000..2dc0496f --- /dev/null +++ b/BZOJ/1059/data/2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4304e0d9dc435e6dcb7d359bb448a8bc8bb11fcc960300ef1fe1e7db808d7975 +size 17 diff --git a/BZOJ/1059/data/3.in b/BZOJ/1059/data/3.in new file mode 100644 index 00000000..cdfc63ff --- /dev/null +++ b/BZOJ/1059/data/3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c2be07087d9d55599c7f7a56b9a4f01ff9316241320c83ef0bdf866f7e4aed63 +size 38868 diff --git a/BZOJ/1059/data/3.out b/BZOJ/1059/data/3.out new file mode 100644 index 00000000..1a536e44 --- /dev/null +++ b/BZOJ/1059/data/3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7f43456e8ba3e1d6a1cf1c904f5ee903f4306bc16631099c608f61ec370d761c +size 43 diff --git a/BZOJ/1059/data/4.in b/BZOJ/1059/data/4.in new file mode 100644 index 00000000..6de99850 --- /dev/null +++ b/BZOJ/1059/data/4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d5eb92c4ae47bdd3c558989a62db281cb84d7a2cfc0623c1deddd81bf9e26f0d +size 1045415 diff --git a/BZOJ/1059/data/4.out b/BZOJ/1059/data/4.out new file mode 100644 index 00000000..4317f747 --- /dev/null +++ b/BZOJ/1059/data/4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:078d428655093806d42bbe56a3b75ca82426d85765055b6db37a109dd516ecd6 +size 72 diff --git a/BZOJ/1059/data/5.in b/BZOJ/1059/data/5.in new file mode 100644 index 00000000..e2bdbd1d --- /dev/null +++ b/BZOJ/1059/data/5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6d448747410d85ceff987ee04c46c0625c65bec018d8ac11f0bc929c59c595b4 +size 209002 diff --git a/BZOJ/1059/data/5.out b/BZOJ/1059/data/5.out new file mode 100644 index 00000000..04033c5c --- /dev/null +++ b/BZOJ/1059/data/5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:097e62729b35307f80c7ae265ba6b0d3b0f297ec2ed657e3d5b1d515622bc44f +size 60 diff --git a/BZOJ/1059/data/6.in b/BZOJ/1059/data/6.in new file mode 100644 index 00000000..f5d1a9c8 --- /dev/null +++ b/BZOJ/1059/data/6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6a4ef080b9bf87cd817b80dbb15e29b4a783b0333e6506eee748e6a6fa710c79 +size 1169595 diff --git a/BZOJ/1059/data/6.out b/BZOJ/1059/data/6.out new file mode 100644 index 00000000..7fa7c56a --- /dev/null +++ b/BZOJ/1059/data/6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6b49deb946fe736d05e78ea558419c1edb3eaccdd3c352e33f62f57f5461b932 +size 70 diff --git a/BZOJ/1059/data/7.in b/BZOJ/1059/data/7.in new file mode 100644 index 00000000..a3073a50 --- /dev/null +++ b/BZOJ/1059/data/7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d9ea0e18a5528607ca93498d72e4139d14286a2fd96699193569e9f0e0838ffc +size 925623 diff --git a/BZOJ/1059/data/7.out b/BZOJ/1059/data/7.out new file mode 100644 index 00000000..1089f784 --- /dev/null +++ b/BZOJ/1059/data/7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7a1e184dd8fc33208663d66d858b6fc08bbb0fe94fe549d4bcc5c245d84c2db8 +size 68 diff --git a/BZOJ/1059/data/8.in b/BZOJ/1059/data/8.in new file mode 100644 index 00000000..544fed95 --- /dev/null +++ b/BZOJ/1059/data/8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:356670e203092edaafb436b06b473e83a57997a87883e14551b6c29094570ed3 +size 14310 diff --git a/BZOJ/1059/data/8.out b/BZOJ/1059/data/8.out new file mode 100644 index 00000000..f2629ceb --- /dev/null +++ b/BZOJ/1059/data/8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:990b2ca7e2bd4de5a15a7ae39fcb05c71dcb2d26162f981356a4ea9308133633 +size 40 diff --git a/BZOJ/1059/data/9.in b/BZOJ/1059/data/9.in new file mode 100644 index 00000000..cb6687ba --- /dev/null +++ b/BZOJ/1059/data/9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5ba358ae9d4cf50c2854c6198f3f0fd273acc0f4295751a58d8faeaddd0955ef +size 295142 diff --git a/BZOJ/1059/data/9.out b/BZOJ/1059/data/9.out new file mode 100644 index 00000000..71cc6d1d --- /dev/null +++ b/BZOJ/1059/data/9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a9d483fdd35db9f83473c9b660c7901cbe37e66c0380adedb228d316ebf9361f +size 63