From 9ab29259291385499aa7e0a9988402936cdbf4f3 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Mon, 21 Nov 2022 19:04:45 +0800 Subject: [PATCH] =?UTF-8?q?#13372.=20=E3=80=8CNOIP2022=E6=A8=A1=E6=8B=9F?= =?UTF-8?q?=E8=B5=9Brdf=E3=80=8D=20=E6=98=A5=E9=A3=8E=E5=8C=96=E9=9B=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit http://www.nfls.com.cn:10611/submission/243388 --- NFLSOJ/13372/13372.cpp | 70 ++++++++++++++++++++++++++++++++++ NFLSOJ/13372/rain.pdf | 3 ++ NFLSOJ/13372/samples/rain1.ans | 3 ++ NFLSOJ/13372/samples/rain1.in | 3 ++ NFLSOJ/13372/samples/rain2.ans | 3 ++ NFLSOJ/13372/samples/rain2.in | 3 ++ NFLSOJ/13372/samples/rain3.ans | 3 ++ NFLSOJ/13372/samples/rain3.in | 3 ++ 8 files changed, 91 insertions(+) create mode 100644 NFLSOJ/13372/13372.cpp create mode 100644 NFLSOJ/13372/rain.pdf create mode 100644 NFLSOJ/13372/samples/rain1.ans create mode 100644 NFLSOJ/13372/samples/rain1.in create mode 100644 NFLSOJ/13372/samples/rain2.ans create mode 100644 NFLSOJ/13372/samples/rain2.in create mode 100644 NFLSOJ/13372/samples/rain3.ans create mode 100644 NFLSOJ/13372/samples/rain3.in diff --git a/NFLSOJ/13372/13372.cpp b/NFLSOJ/13372/13372.cpp new file mode 100644 index 00000000..309b5f93 --- /dev/null +++ b/NFLSOJ/13372/13372.cpp @@ -0,0 +1,70 @@ +#include +#include +#include + +// using std::cin; +// using std::cout; +std::ifstream cin("rain.in"); +std::ofstream cout("rain.out"); +const char endl = '\n'; + +const int N = 2505; + +int n, m, k, a[N], b[N], tag[N], match[N], ans; +std::vector g[N]; + +bool dfs(int u, int t) { + if (tag[u] == t) return false; + + tag[u] = t; + + for (int v : g[u]) { + if (!match[v]) { + ans -= a[u]; + match[v] = u; + return true; + } else if (dfs(match[v], t)) { + ans += a[match[v]]; + ans -= a[u]; + match[v] = u; + return true; + } + } + + return false; +} + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> n >> m >> k; + + for (int i = 1; i <= n; i++) { + cin >> a[i]; + + ans += a[i]; + } + + for (int i = 1; i <= n; i++) { + cin >> b[i]; + + ans += b[i]; + } + + for (int i = 1, x, y; i <= m; i++) { + cin >> x >> y; + + if (a[x] == b[y]) { + g[x].emplace_back(y); + } + } + + for (int i = 1; i <= n; i++) { + dfs(i, i); + } + + cout << ans << endl; + + return 0; +} diff --git a/NFLSOJ/13372/rain.pdf b/NFLSOJ/13372/rain.pdf new file mode 100644 index 00000000..8ea6b8c9 --- /dev/null +++ b/NFLSOJ/13372/rain.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cb9dd5f527499d84f291f5d973312f236d87efa58f24c2817f26636122345a39 +size 272547 diff --git a/NFLSOJ/13372/samples/rain1.ans b/NFLSOJ/13372/samples/rain1.ans new file mode 100644 index 00000000..04800c56 --- /dev/null +++ b/NFLSOJ/13372/samples/rain1.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9b6dd0f55d1cea37555db317f53a0631f694bd46df8018cc2aeed3d9e2f32f5f +size 3 diff --git a/NFLSOJ/13372/samples/rain1.in b/NFLSOJ/13372/samples/rain1.in new file mode 100644 index 00000000..e60b1bbd --- /dev/null +++ b/NFLSOJ/13372/samples/rain1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5f70aa07fd4fddec13556b422f0844196032a76bbe6e29c09ad59f7f9cf78429 +size 108 diff --git a/NFLSOJ/13372/samples/rain2.ans b/NFLSOJ/13372/samples/rain2.ans new file mode 100644 index 00000000..252d9af3 --- /dev/null +++ b/NFLSOJ/13372/samples/rain2.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b6589f062eb6804f0f1acd6e65a9f26093ef0973fc30d4632a42a9b36f7c7976 +size 4 diff --git a/NFLSOJ/13372/samples/rain2.in b/NFLSOJ/13372/samples/rain2.in new file mode 100644 index 00000000..b57ee6b1 --- /dev/null +++ b/NFLSOJ/13372/samples/rain2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c7d2832fd637e3128618d9886121c04e06412b96894ae1e38438c9043c548a43 +size 7283 diff --git a/NFLSOJ/13372/samples/rain3.ans b/NFLSOJ/13372/samples/rain3.ans new file mode 100644 index 00000000..5256742b --- /dev/null +++ b/NFLSOJ/13372/samples/rain3.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d282ea0ca6a8bacf9bb21b535474f4e733c74205d3f71f205a059ee7b9103992 +size 12 diff --git a/NFLSOJ/13372/samples/rain3.in b/NFLSOJ/13372/samples/rain3.in new file mode 100644 index 00000000..20d9476e --- /dev/null +++ b/NFLSOJ/13372/samples/rain3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:87e1c29170b14466ca0dfb962ef8441571b71af81335371b97d86c2f3d9ee2e5 +size 7936065