QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#791700 | #898. 二分图最大匹配 | Mr_Min | WA | 50ms | 9944kb | C++14 | 1014b | 2024-11-28 20:28:18 | 2024-11-28 20:28:24 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int l, r, m;
cin >> l >> r >> m;
vector < vector < int > > g(l);
for (int i = 1, u, v; i <= m; i++) {
cin >> u >> v;
g[u].push_back(v);
}
vector < int > mch(r, -1), vis(r, -1);
auto dfs = [&](auto &self, int u, int t) -> int {
if (vis[u] == t) return 0;
vis[u] = t;
for (int v : g[u])
if (vis[v] != t && mch[v] == -1) return mch[v] = u, vis[v] = t, 1;
for (int v : g[u]) {
if (vis[v] != t) {
if (vis[v] = t; self(self, mch[v], t)) return mch[v] = u, 1;
}
}
return 0;
};
int ret = 0;
vector < int > ord(l);
iota(ord.begin(), ord.end(), 0);
shuffle(ord.begin(), ord.end(), mt19937 (random_device{}()));
for (int i : ord) ret += dfs(dfs, i, i);
cout << ret << '\n';
for (int i = 0; i < r; i++) {
if (~mch[i]) cout << mch[i] << ' ' << i << '\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 50ms
memory: 9944kb
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:
99936 12041 0 88633 1 5283 2 85610 3 42164 4 76685 5 92014 6 72044 7 70240 8 58488 9 43951 10 20110 11 30466 12 4229 13 46522 14 59008 15 62176 16 35924 17 32625 18 4961 19 85970 20 83385 21 99925 22 76846 23 36019 24 21960 25 97056 26 38043 27 24373 28 25033 29 16929 30 59580 31 49575 32 4755 33 61...
result:
wrong answer # of Matching is differ - expected: '100000', found '99936'