QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#481312 | #898. 二分图最大匹配 | 24bot | WA | 667ms | 14480kb | C++14 | 707b | 2024-07-16 23:25:30 | 2024-07-16 23:25:31 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int n, m, E, mch[100005], vis[100005];
vector<int> G[100005];
bool dfs(int x) {
if (vis[x]) return 0; vis[x] = 1;
for (int y : G[x])
if (!mch[y] || dfs(mch[y])) return mch[y] = x, 1;
return 0;
}
int main(void) {
ios::sync_with_stdio(0);
cin >> n >> m >> E;
for(int i = 1; i <= E; i++) {
int u, v; cin >> u >> v; ++u; ++v;
G[u].push_back(v);
}
int ans = 0;
for (int i = 1; i <= n; i++) if (dfs(i)) {
memset(vis, 0, sizeof(vis));
++ans;
}
cout << ans << endl;
for (int i = 1; i <= n; ++i)
if (mch[i]) cout << i - 1 << " " << mch[i] - 1 << "\n";
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 667ms
memory: 14480kb
input:
100000 100000 200000 78474 45795 32144 46392 92549 13903 73460 34144 96460 92850 56318 77066 77529 84436 76342 51542 77506 99268 76410 89381 1778 61392 43607 96135 84268 74827 14857 35966 32084 94908 19876 174 1481 94390 12423 55019 64368 92587 81295 7902 25432 46032 36293 61128 73555 84836 8418 102...
output:
100000 0 12041 1 72487 2 5283 3 69829 4 42164 5 90712 6 92014 7 59953 8 71269 9 58488 10 96208 11 72327 12 57264 13 60846 14 52381 15 59008 16 50389 17 35924 18 32625 19 21527 20 27578 21 47990 22 90601 23 76846 24 36019 25 21960 26 56983 27 38043 28 92270 29 25033 30 16929 31 23472 32 49575 33 7705...
result:
wrong answer Matching is incorrect (0, 12041)