0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-08 14:18:47 +00:00

#13372. 「NOIP2022模拟赛rdf」 春风化雨

http://www.nfls.com.cn:10611/submission/243388
This commit is contained in:
Baoshuo Ren 2022-11-21 19:04:45 +08:00
parent dda252595e
commit 9ab2925929
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
8 changed files with 91 additions and 0 deletions

70
NFLSOJ/13372/13372.cpp Normal file
View File

@ -0,0 +1,70 @@
#include <iostream>
#include <fstream>
#include <vector>
// 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<int> 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;
}

BIN
NFLSOJ/13372/rain.pdf (Stored with Git LFS) Normal file

Binary file not shown.

BIN
NFLSOJ/13372/samples/rain1.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
NFLSOJ/13372/samples/rain1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
NFLSOJ/13372/samples/rain2.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
NFLSOJ/13372/samples/rain2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
NFLSOJ/13372/samples/rain3.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
NFLSOJ/13372/samples/rain3.in (Stored with Git LFS) Normal file

Binary file not shown.